Python Forum
MyProgrammingLab wont accept anything I put in
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
Reply
#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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Program that allows to accept only 10 integers but loops if an odd number was entered gachicardo 4 3,548 Feb-24-2022, 10:40 AM
Last Post: perfringo
  I will accept any help with this task (compression code) Malin3k 3 2,255 Feb-10-2021, 10:20 AM
Last Post: Larz60+
  Help With MyProgrammingLab Code Problem alex_0 2 3,712 Jan-31-2021, 03:38 AM
Last Post: BashBedlam
  Why wont this work? samh625 6 3,264 Jul-30-2020, 08:30 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020