0

I am writing a terminal based project for a course using python. At the moment my code looks like this:

user_input = input("Please input your age here")
print(f"Your age is {user_input} years old")

And in the terminal looks like:

Please input your age here
25
Your age is 25 years old

I want to hide where the user has put 25, ie. I want the terminal readout to look like;

Please input your age here
Your age is 25 years old

It may not be possible but as the user interface s the terminal I want it to look as clean as possible

0stone0
  • 34,288
  • 4
  • 39
  • 64

1 Answers1

2

Use getpass:

from getpass import getpass
user_input = getpass("Please input your age here")
print(f"Your age is {user_input} years old")

Getting a hidden password input

Freddy Mcloughlan
  • 4,129
  • 1
  • 13
  • 29
  • Obvious duplicate, you even pasted a link to the dupe, why not vote to close? – 0stone0 Jun 07 '22 at 10:44
  • @0stone0, because I don't have 3k rep. I upvoted your comment on the duplicate. I'm posting an answer because OP asked a question, it's not against the rules to post an answer on a possible duplicate – Freddy Mcloughlan Jun 07 '22 at 10:47
  • hello, i wasnt aware of a duplicate question, if i posted more than once im sorry, pretty new here and first time posting, just couldnt find an answer elsewhere – lisa-underwater Jun 07 '22 at 13:10
  • @lisa-underwater that's okay :), the [rules](https://stackoverflow.com/help/asking) may be worth reading before posting another question – Freddy Mcloughlan Jun 07 '22 at 23:26