Apr-01-2017, 10:24 PM
(Apr-01-2017, 10:13 PM)sparkz_alot Wrote: "requires me to use nested if-statements (not lists) in order to write a function". I presume that means dictionary's as well :-).I was just about to comment that. It very confusing, i mean are "lists" considered "tuples"/"dictionaries"; Guess the context of the question is not really clear.
@
Quote:Liquid_Ocolet
if translate == "German": if words == "dog": print("The Translation of dog into German is 'hond'") elif words == "cat": print ("The translation of cat into German is 'katze'") else: print("I can not understand")There is something not correct here, so the users input "GERMAN" language and is supposed to enter the words in "ENGLISH".
And converting it into a simple function
def trans(language, words): if language == "French": if words == "chien": print("English => Dog") print("Dutch => hond") elif words == "chat": print("English => Cat") print("Dutch => kat") else: print("I can not understand") # KEEP ADDING ELIF FOR ALL THE OTHER WORDS if language == "English": if words == "dog": print("French => chien") print("Dutch => hond") elif words == "cat": print("French => chat") print("Dutch => kat") # KEEP ADDING ELIF FOR ALL THE OTHER WORDS else: print("I can not understand") language = raw_input("What do you want to translate to :") words = raw_input("Please state the word :") trans(language, words)