anonymous
  • anonymous
Infinite loop problems. Used this code: To write an infinite loop, use True as the condition: while (True): i = getInput() print("input is",i) process(i) Got this error: Traceback (most recent call last): File "/Users/nfsiddiqui/Documents/whileloop.py", line 18, in i = getInput() NameError: name 'getInput' is not defined Using: Python 3.3.2 [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Was going through this: http://beastie.cs.ua.edu/cs150/book/index_14.html Please advise on what the error is.
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
e.mccormick
  • e.mccormick
It is saying that you never defined a function called getInput(). That example is using a non-standard function.
e.mccormick
  • e.mccormick
As a standard function, if it was for user input, you would use raw_input() or input() in python2.x, and input() or eval(input()) in python3.x. For the example listed, I would do something different. The goal is to show you an infinite loop, which is a BAD thing to make. An easy one is this: i=0 while (True): i = i+1 print(i) Note, the above code is python 3.x code. I can tell because of the () around what you are printing. In 2.x, it woull be slightly different.
e.mccormick
  • e.mccormick
And you use control-c to stop it when you get tired of seeing numbers whiz by.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Thanks, just tried your infinite loop and it worked. The commands get input, raw input, eval input...do they change every time a new version of python is released? Or am I not understanding what they are for?
e.mccormick
  • e.mccormick
2.x has flaws. 3.x is a major overhaul, but they don't expect full implementation for about another year or two. So at this point 2.x is still more popular, but 3.x is very popular. They gave a 5 year plan for the change over, and it is 4 years in....

Looking for something else?

Not the answer you are looking for? Search for more explanations.