main.py594 chars20 lines
To explain the code above:
We first import the random
module, which we will use to choose a random element from the hiragana
list.
We define the hiragana
list, which contains all the Hiragana characters of the Japanese alphabet.
We use random.choice(hiragana)
to choose a random element from the hiragana
list and assign it to the rand_hiragana
variable.
We print out the randomly chosen Hiragana character in green color by using ANSI escape codes. We start the string with "\033[32m"
to turn the color green (\033[32m), then add the random character, and end the string with "\033[0m"
to reset the color back to the default.
gistlibby LogSnag