Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MyProgrammingLab wont accept anything I put in
#1
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
ichabod801 wrote Feb-10-2019, 11:13 PM:
Please use python and output tags when posting code and results. I put them in for you this time. Here are instructions for doing it yourself next time.
Quote
#2
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.
nilamo likes this post
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#3
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!
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Water flow sensor and Servo Motor wont run at the same time baff_paff 1 106 Apr-16-2019, 09:47 AM
Last Post: baff_paff

Forum Jump:


Users browsing this thread: 1 Guest(s)