Reputation: 11
So in Python, the user places input on a line in the console and it stays there. I want the code to basically print over the previous input line, covering the user input on the last line with a printed string. Is there any way to do that?
How many planets are in the solar system?
#user inputs answer on this line
--->
How many planets are in the solar system?
correct
Upvotes: 1
Views: 521
Reputation: 1101
A quick fix would be to clear the console with os.system('cls') and re-print the question.
import os
print('How many planets are in the solar system?')
value = int(input())
os.system('cls')
print('How many planets are in the solar system?')
if value == 8:
print('Good job you are right!')
else:
print('You are wrong.')
Before the clear:
How many planets are in the solar system?
3
After the clear:
How many planets are in the solar system?
You are wrong.
This works great and doesn't require much code.
Upvotes: 1