0
String Input Help
I was needing help with this situation. The question on a problem for a lesson said,â x = input(Enter a Number: ) print(x) â It says that the âuserâ entered 4 into the input. The final answer to the question was 4. But when I actually ran a code like that, it said âEnter a Number: 4â Is there a way to tell the user, âenter a numberâ without it popping up in the output when printed?
4 Answers
0
perhaps conditions when user inputs invalid type?
x = input()
if not x.isdigit():
print("Enter a number")
+ 5
If you don't want the instruction "Enter a number" to show up in the output, you may have to use a graphical user interface like tkinter (which SoloLearn doesn't support) - e.g. https://www.python-course.eu/tkinter_entry_widgets.php.
If you just want the instruction and input on separate lines, you can do
x = input("Enter a Number:\n" )
0
the input youâve given has prompt, which are messages joined with the input. Simply remove it
x = input()
0
I still, however wish to tell them to put integers. Not letters or something. would that require coding in html, css, and/or js too?