Ok, while deciding what recipes I would shop for now that I’m unemployed (because obviously when you’re unemployed it is time to COOK ALL THE TIME), I decided to make a lil Python program that will let me enter recipes, and at a point in the future, probably after I learn regex, make it fully searchable. I’m already separating things out for ease of searching – like lists both with and without quantity indications.
Problems I’ve solved: a) making a new file name out of whatever the user enters, and b) setting a var for the long combination of dir, name & .txt that I’ll use in a few different places throughout the program
global new_filename new_filename = "recipes/" + new_recipe + ".txt" open(new_filename, 'a') # 'a' for append
Iterating through a list which adds to another list with some clever while
looping
def ingredient_input(): ingredient = 0 # is it ok to set this var to a dummy value? it gets redefined with each loop. while ingredient != 'DONE': print "what is the ingredient? no measurements yet, please. type DONE" print "in all-caps if no more." ingredient = raw_input("> ") if ingredient == 'DONE': ingred_check() else: ingredients.append(ingredient)
And there are plenty of problems I haven’t solved yet. Will write more soon! Unemployed coding is fun, ha ha! “Hmm, let me chew on this juuuust a bit more… oh my god how did 3pm get here” etc etc : )