Facebook status turned into a recursion program — Python Programming
I was lamenting (which I obviously do a lot) about stuff and wrote a facebook status – written below. One of my friends mentioned that it was a recurrence relation that should be tested which I immediately took as a challenge and coded it. This was what I needed after struggling to understand Java syntax which is something I find to be an extreme opposite of Python.
Status:
Completely lost trying to program because I have to miss class because I have to go to work because I have to make money because I have to pay for college because I have to pay for class that I have to miss because I have to go to work because I have to make money because I have to pay for college because I have to pay for class that I have to miss because I have to go to work because I….need a vacation….
def func (var): if var == "I have to miss class": return 1 if var == "I have to go to work": return 2 if var == "I have to make money": return 3 if var == "I have to pay for college": return 4 if var == "I have to pay for class": return 5 def status(variable): if variable == 5: return 1 else: return (variable + 1) def twice(var): if var == 1: return "I have to miss class" if var == 2: return "I have to go to work" if var == 3: return "I have to make money" if var == 4: return "I have to pay for college" if var == 5: return "I have to pay for class" def main(): variable = 1 while 1>0: variable = input("Completely lost in programming because ") because = func(variable) recur = status(because) reverse = twice(recur) print(variable, "because", reverse) main()