私はちょうどPythonを学び始めました。Pythonでループの問題が発生する
私はPig Latin Converterのコードを書こうとしています。私はそれを書くために関数を使用しています。私はwhileループで走ります。
ブレークを使用してループを終了する方法を理解しようとしましたが、それは終了しません。また、2回目に入力するだけで動作します。
私が間違っていることを見つけたいと思っています。もしあなたが私を助けてくれたら、本当に感謝しています。 :)
pig = 'ay'
def func():
word = input('Hello. Please Enter your First Word:').lower()
if len(word) > 0 and word.isalpha():
first = word[0]
if first in ('a', 'e', 'i', 'o', 'u'):
print('The first letter must begin with a consonant. Would you like to try a different word? (Y/N)') and inpup().lower()
if input() == 'y':
return func()
else:
print("Thank you for using Pig Latin Converter")
return False
else:
new_word = word[1].upper() + word[2:] + ' ' + first.upper() + pig
print(new_word)
print("Would you like to try a different word? (Y/N)") and input().lower()
if input() == 'y':
return func()
else:
print("Thank you for using Pig Latin Converter")
return False
while True:
func()
if False:
break
'if func():break' – abccd