I looked on stackoverflow to solve my problem but from all explanations about loops and checks I don't understand why my code isn't working. So I want to build a dictionary (totally new to Python btw) and I read that I can also check if the input is in the dicitonary module but that is actually not what I want to do here. I just want to see if the raw_input contains at least one number in the string (not if the string only contains numbers) and if the length of the input string is at least 2. If the input passes those checks it should move on (the rest of this dictionary will come later. For now I only want to understand what I did wrong with my check) Here's my code, help would be very much appreciated!
def check():
if any(char.isdigit() for char in original):
print ("Please avoid entering numbers. Try a word!")
enter_word()
elif len(original)<1:
print ("Oops, you didn't enter anything. Try again!")
enter_word()
else:
print ("Alright, trying to translate:")
print ("%s") %(original)
def enter_word():
original = raw_input("Enter a word:").lower()
check()
enter_word()
Aucun commentaire:
Enregistrer un commentaire