0

I am trying to create a loop for python to create a variable of different input values.
I want to input 3 different words into the name variable. This is my code:

name = raw_input("What is your name? ")  
if len(name) > 0:  
    print name  

I want to repeat the action from the input till I stop input.

1

1 Answer 1

2

Maybe (although I'm not sure if I understand what you're asking for)

n = 0
while n < 3:
    name = raw_input('What is your name?')
    if name:
        print name
        n + =1

The variable name will change each time, keep in mind.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.