0

I'm writing a simple program that is basically a signup program for a run. I am very new to python, but cant seem to find out why this isn't working. My error message is saying something is wrong with line 9. I would really appreciate if someone could help me work this out. I have been looking around for ages trying to find solutions, it's probably a very easy mistake.

Cheers!!

    allnames = []
    allages = []
    allgenders = []
    alltimes = []
    allhouses = []
    more = "yes"
    print "---- RUN ----"
    while (more) == "yes":
      runnername = input("Input runner name:")
      allnames.append(runnername)
      print str(allnames)

Thanks for all the help! Got it now. It's for NAT 5 Computing so i'm very new and inexperienced. Appreciate everyones answers!!

6
  • If you are using Python2 (and from the looks of it you are because print wouldn't work without parenthesis) then you want raw_input, not input. Commented Oct 7, 2017 at 16:45
  • @AntonvBR you're a lifesaver! I knew it would be something easy. Care to help a poor man out? What exactly does raw input do differently from just input? Cheers!! Commented Oct 7, 2017 at 16:46
  • @lmxx How about google it? :) Here is what I found: Read more here: stackoverflow.com/questions/4915361/… Commented Oct 7, 2017 at 16:46
  • Or just search this site: stackoverflow.com/questions/4915361/… Commented Oct 7, 2017 at 16:48
  • 2
    Possible duplicate of input() error - NameError: name '...' is not defined Commented Oct 7, 2017 at 16:48

5 Answers 5

1

Use this:

while (more == "yes"):

instead of :

while (more) == "yes":

and it should work fine.

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

Comments

1

Change:

input() to raw_input()

Read more here: What's the difference between raw_input() and input() in python3.x?

Comments

1

You're in an infinite loop. Try this:

allnames = []
more = "yes"

print "---- RUN ----"

while more == "yes":
      runnername = raw_input("Input runner's name: ")
      allnames.append(runnername)
      if len(allnames) == 5:
          more = "no"

print allnames

Change the condition in if len(allnames) == 5 according to your requirement.

Comments

1

in this code you have looking ages also. In your code you miss the '()' bracket in print statment and also miss secound time run statment for ages.

allnames = []
allages = []
allgenders = []
alltimes = []
allhouses = []
more = "yes"
print("---- RUN ----")
while (more) == "yes":
    runnername = input("Input runner name:")
    allnames.append(runnername)
    print(str(allnames))

    runnerages = input("Input runner ages:")
    allages.append(runnerages)
    print(str(allages))

Comments

0

You are getting error beacuse of input(). Replace it with raw_input() for python2.X .

Then try this way :

allnames = []
allages = []
allgenders = []
alltimes = []
allhouses = []
more = "yes"
print "---- RUN ----"
while (more) == "yes":
  runnername = raw_input("Input runner name:")
  allnames.append(runnername)
  print str(allnames)

N.B: python2.X

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.