Stuck on Continue Statement: Solving a Python Coding Problem

  • Context: Python 
  • Thread starter Thread starter mockingbird
  • Start date Start date
  • Tags Tags
    Coding Python Stuck
Click For Summary

Discussion Overview

The discussion revolves around a Python coding problem related to the use of the continue statement within a while loop. Participants are exploring issues with input handling and error messages encountered while running the code. The scope includes coding practices and debugging techniques.

Discussion Character

  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant shares their code and describes the error message they receive when trying to run it, indicating confusion about the input function and its expected behavior.
  • Another participant references an external resource that outlines control flow in Python, suggesting that the original poster may not have implemented the code correctly.
  • A third participant expresses frustration and embarrassment about their coding difficulties but appreciates the feedback and assistance from others.

Areas of Agreement / Disagreement

The discussion does not reach a consensus on the specific issue at hand, as the original poster is still seeking clarity on the problem, and responses vary in their focus on different aspects of the code.

Contextual Notes

Participants have not fully clarified the nature of the input error or the specific differences between the shared code and the referenced example. There may be assumptions about the environment or Python version that are not explicitly stated.

mockingbird
Messages
3
Reaction score
0
I Have been using A Byte of Python, and I am now stuck on the Continue Statement. Here is my code.

#!/usr/bin/python
#Filename: continue1.py

while True:
s = input('Enter something : ')
if s == 'quit':
break
if len(s) < 3:
print('Too Small')
continue
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.
 
Technology news on Phys.org


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

I am pretty sure that I am putting everything in the way he is telling me.
 
Last edited by a moderator:


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.
 

Similar threads

Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
12
Views
2K