Before I ask my question, you should know I have little to no experience with programming. Is there a way I can use an if function to determine if the first letter of a string is a vowel and if not, then print something else?
I've done quite a bit of research and the answers I found were too far advanced for me to understand. This is a small challenge I've handed myself that is based off of CodeAcademy's 'Pyg Latin' Translator
translate = input("Translate: ")
cons = "ay"
vowel = "way"
if len(translate) > 0:
switch = str(translate[0])
if str(translate[0]) != "a, e, i, o, u":
new_word = str(translate) + str(switch) + str(cons)
print (new_word.lower())
else:
new_word = str(translate) + str(vowel)
print (new_word.lower())
else:
print("Please type something")
The job is to add "Way" or "Ay" depending on whether 'translate' begins with a vowel. I feel as though i'm skipping over something completely obvious but I can't figure it out. Thank you for your help!
Aucun commentaire:
Enregistrer un commentaire