Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Python problem

  1. Aug 31, 2009 #1
    I Have been using A Byte of Python, and I am now stuck on the Continue Statement. Here is my code.

    #Filename: continue1.py

    while True:
    s = input('Enter something : ')
    if s == 'quit':
    if len(s) < 3:
    print('Too Small')
    print('Input is of sufficient Length')
    #Do other kinds of Processing here...

    I keep getting this...

    andrew@andrew-laptop:~$ python continue1.py
    Enter something : a
    Traceback (most recent call last):
    File "continue1.py", line 5, in <module>
    s = input('Enter something : ')
    File "<string>", line 1, in <module>
    NameError: name 'a' is not defined

    I am completely new at this, but I have 1. Spent more than two hours trying to figure this out. 2. Looked online for longer than an hour to find an example of what I have done wrong. 3. Stared at this problem until my eyes have bled.
    I hope someone can/will help me figure this out. I am using gedit that came with my version of Ubuntu. I don't know if that will change anything.
  2. jcsd
  3. Aug 31, 2009 #2
    Re: What language? is python good?

    Well my code didn't come out properly, here is the link that I am imitating. The Break Statement and the Continue Statement are the ones that aren't working.

    http://www.swaroopch.com/notes/Python_en:Control_Flow [Broken]

    I am pretty sure that I am putting everything in the way he is telling me.
    Last edited by a moderator: May 4, 2017
  4. Aug 31, 2009 #3

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

  5. Aug 31, 2009 #4
    Re: What language? is python good?

    Hey! Thanks man, I glad you pointed that out to me. Like I said, was probably a really easy, simple, stupid fix. I feel embarassed now, but like I said I was copying his code, and couldn't figure anything out. Really Appreciate you helping a Noob out.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook