Python Forum
MyProgrammingLab wont accept anything I put in - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: MyProgrammingLab wont accept anything I put in (/thread-16015.html)



MyProgrammingLab wont accept anything I put in - chicks4 - Feb-10-2019

Hi! So, I am extremely new to Python and coding. I have this homework assaignment due tonight. I feel like I am sooo close, but for whatever reason MyProgrammingLab wont accept anything I put in. Maybe its my spacing? The assaignment is due tonight. Please help!!
Question:
You have a unique ID number, which is represented by the variable id, containing a string of numbers. Write a program that continuously takes strings to standard input. If the string is not your ID number, print "This is not your ID number." If it is, print "This is your ID number: " followed by the number, and terminate the loop.

My Code:
number = input()
while number != id:
	print("This is not your ID number.")
number = input()
	print("This is your ID number:", id)
Thank you to anyone with advice! Heart Blush Big Grin


RE: HELLLP! - ichabod801 - Feb-10-2019

Reverse the indents on line 4 and 5. Line 4 should be part of the loop (you need to keep asking the question), and line 5 should only be executed after the loop is done.

If the value in id is an integer, you will need to convert the input you get with the int() built-in function.

Using id as a variable name is a bad idea. That is the name of a built-in function, and by using it as a variable name, you lose access to that function. I realize your teacher is telling you to use it, but just be aware that they are not teaching you best Python practices.


RE: MyProgrammingLab wont accept anything I put in - chicks4 - Feb-10-2019

I apologize for not adding tags! Thanks for doing that for me.
Also, you are right. Switching the indention worked!
And thank you for the advice about the variable, I will keep that in mind.
Thanks so much for the help, it is truly appreciated!