(Apr-10-2017, 03:43 PM)Low_Ki_ Wrote: This is how I normally avoid this:
def main(): # Declaring the necessary variables and dictionary. large, small = 0, 0 items = {} while True: # The following is our main menu that the user will see. userin = input( "Type 'i' to enter new items, 'r' to begin registering new families, or 't' to get currnet total and stats, e is to exit: ") if userin.lower() == 'i': food_items(items) elif userin.lower() == 'r': large, small = one_or_two(large, small) elif userin.lower() == 't': total(large, small, items) elif userin.lower() == 'e': total(large, small, items) final_total(large, small, items) break else: print('An unknown option: ', userin, ' has been entered. Please try the last entry again.')
Much better to do one single:
userin=lower(input("...........")Otherwise, a dictionary of functions looks like a palatable option.
(Apr-10-2017, 03:43 PM)Low_Ki_ Wrote: Or you can add an 'or' statement to the string saying...:Certainly not:
if userin == 'i' or 'I': food_items(items)
if userin == 'i' or userin =='I': food_items(items)or
if userin in ['i','I']: food_items(items)
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Your one-stop place for all your GIMP needs: gimp-forum.net