# Webinar Input Patterns # Sept 10, 2022 # input() ALWAYS returns a string # myInput = input() # # but we might want to change it to something else... # 1 Turn a numeric string into an int or float # 2 Breaking up a long string into a list of smaller strings # 3 Break up a string containing numeric chars into a list of # recast ints or floats # 4 One value tells you how many times to call input() # 5 We DON'T KNOW how many times to call input(), but we know # a sentinel value to stop # 1 Turn a numeric string into an int or float # myInput = input() # myInput = "5" # myInput = int(input()) # float(input()) # 2 Breaking up a long string into a list of smaller strings # myInput = "Pat Silly Doe" # input() # strList = myInput.split() # str split() turns a long str into a list of short str # print(strList) # 3 Break up a string containing numeric chars into a list of # recast ints or floats # # Lab 28.11... 10 5 3 21 2 # myInput = "31 567 2 93 6" # input() # strList = myInput.split() # print(strList) # numList = [] # for num in strList: # numList.append(int(num)) # print(numList) # you could do this with a LIST COMPREHENSION # [expression for item in other container] # myInput = "2 34 87 234 99" # input().split() # strList = myInput.split() # numList = [int(num) for num in strList] # print(numList) # 4 One value tells you how many times to call input() # for example 6.17 # example inputs for 6.17: # 5 # 30.0 # 50.0 # 10.0 # 100.0 # 65.0 # numValues = 5 "# int(input()) # floatValues = [] # for n in range(0, numValues): # first input # nextInput = float(input()) # floatValues.append(nextInput) # # # to finish out that Lab... # theMax = max(floatValues) # for num in floatValues: # print("{:.2f}".format(num/theMax)) # 5 We DON'T KNOW how many times to call input(), but we know # a sentinel value to stop # Lab 33.15 # March 1, 1990 # April 2 1995 # 7/15/20 # December 13, 2003 # -1 # ask for the FIRST input() myInput = input() # THEN we can loop... while myInput != "-1": # do our stuff myInput = input() # last thing... get the next input() # multiple quit commands # Done, done, d myInput = input().strip() # I haven't been stripping inputs, but it's always a good idea! # while myInput != "Done" and myInput != "done" and myInput != "d": quitCommands = ["Done", "done", "d"] while myInput not in quitCommands: # do your stuff myInput = input().strip()