I'm having some problems with my code, I have included the prompt and my code below.
Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways.
Write a program that takes a string and an integer as input, and outputs a sentence using the input values as shown in the example below. The program repeats until the input string is quit and disregards the integer input that follows.
Ex: If the input is:
apples 5 shoes 2 quit 0 the output is:
Eating 5 apples a day keeps the doctor away. Eating 2 shoes a day keeps the doctor away.
My code:
word = ''
tokens = ''
while True:
print('Eating {} {} a day keeps the doctor away.'.format(tokens[0],tokens[1]))
word = input()
tokens = input().split()
if tokens == 'quit':
break
while True:
tokens = input().split()
if tokens == ['quit']:
break
print('Eating {} {} a day keeps the doctor away.'.format(tokens[0],tokens[1]))
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments