Question:
My code is being weird and I have spend a long time trying to fix it, can anyone help?
Current behavior:
Somewhere after line 151 is ran, it stops and doesn’t even end the program. It just continues to ask for an input.
Desired behavior
After you enter your input, it should start a practice.
Repl link:
https://replit.com/@randomcat962/Type-in-Japanese?v=1
Sorry if this is the wrong link. I’m not sure which link I’m supposed to add.
def katakana_practice():
def multi_character_variable():
character_lengths = [1, 2, 3, 4, 5]
character_lenth = random.choice(character_lengths)
if character_lenth == 1:
output = random.choice(katakana)
elif character_lenth == 2:
output = random.choice(katakana) + random.choice(katakana)
elif character_lenth == 3:
output = (
random.choice(katakana) + random.choice(katakana) + random.choice(katakana)
)
elif character_lenth == 4:
output = (
random.choice(katakana)
+ random.choice(katakana)
+ random.choice(katakana)
+ random.choice(katakana)
)
else:
output = (
random.choice(katakana)
+ random.choice(katakana)
+ random.choice(katakana)
+ random.choice(katakana)
+ random.choice(katakana)
)
return output
finished_practicing = False
first_question = True
character = "ND"
print(
"Would you like to practice one character at a time, or several? Enter '1' to do one character at a time, or '+' to do more."
)
user_input = input()
if user_input == "1":
while finished_practicing == False:
if first_question:
character = random.choice(katakana)
first_question = False
print("Please enter", character)
user_input = input()
if user_input == character:
character = random.choice(katakana)
print(
"Correct! Enter 'X' to end the program. If you want to continue, you can press enter."
)
user_input = input()
if user_input == "X":
finished_practicing = True
else:
print("That's incorrect.")
if user_input == "+":
while finished_practicing == False:
if first_question:
character = multi_character_variable()
first_question = False
print("Please enter", character)
user_input = input
if user_input == character:
character = multi_character_variable()
print(
"Correct! Enter 'X' to end the program. If you would like to continue, please press the enter key."
)
user_input = input()
if user_input == "X":
finished_practicing = True
else:
print("That's incorrect")