How do I fix my code for Python Mad lips loops?

Luna_Dragon

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
MoRe
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.

edited at
0

Comments

0 comments
Login to comment

Related

How do I refactor my code to reduce the amount of nested loops?

How do I fix the image in my Python game?

My code keeps displaying an error when I run it on Python Tutor saying: "Too many to unpack". How do I fix this error?

How do I fix the indentation error in my code?

How to fix this my error code program? I use Python 3.6

How do I fix my code for plotting a histogram?

How do I fix my code for my recursive countdown python function so that it only prints “LIFT OFF!’ once?

How can I fix my code to solve for this puzzle? (Python)

How do I fix my code for insert into SQL Server with Python 3.7

How do I fix my string integer issue in Python

how do I fix my code in order to display one table?

How do I fix Webpack from mangling my code in production?

How can i improve my python code regarding while loops

How do i fix my code's vulnerability?

Cannot identify Error reasoning - Related to ArrayList and FOR loops, how could I fix my code?

How do I fix my conditional statement for marks input in Python?

How can I fix my for loops for a card game?

how do i fix my problem with my tuple in python

How can I fix this error in my python code?

How do i fix my class code 'int' object error?

How do I fix my code about a script that stopped working?

How do I fix my ctx not working (Discord Bot in Python)?

How do I fix my code with Pygame to jump correctly?

How to fix a Mad Lib in python?

How do I fix my code so that it is automated?

how do i fix this subprocess error in my code

Error in Python Code. How do I fix a skip?

What can I do to fix my code with this HLSL error about array references in loops?

How do I fix my duplicate detection code? Java

TOP Ranking

HotTag

Archive