''' DS2000 Fall 2024 Sample code from class - fun with python lists! Goal: * Read in one line from the CSV file using readline() * Turn into a list of strings using split(",") * Turn into a list of integers using int() * Answer some questions about the dice game results, like... - how many times was the $$ even? - when did we make > $10 on a roll? ''' FILENAME = "dicemoney.csv" def main(): # Step one: gather data by reading from the file (csv with one line) with open(FILENAME, "r") as infile: row = infile.readline() print("After readline, here is row:", row) # Turn row (string) into a list of strings outcomes = row.split(",") print("After split, here is outcomes:", outcomes) # Create a new list, but with integer values outcome_nums = [] for value in outcomes: var = int(value) print("inside for loop", outcome_nums) outcome_nums.append(var) print("After converting to int, here is outcome_nums", outcome_nums) # How many times did we get an even amount of money? count = 0 for num in outcome_nums: if num % 2 == 0: print("even!") count = count + 1 print("I saw even $", count, "times!") main()