0

How can I input int or string from the user in Python.

user = input("Enter a number or name of person")
  • 1
    Does this answer your question? [How can I check if a string represents an int, without using try/except?](https://stackoverflow.com/questions/1265665/how-can-i-check-if-a-string-represents-an-int-without-using-try-except) – Gabriel Pellegrino May 04 '22 at 16:17

1 Answers1

0
user = input("Enter a number or name of person: ")

You want to check if it's an int?

user = input("Enter a number or name of person: ")
try:
    int(user)
except ValueError:
    # The type isn't int
FLAK-ZOSO
  • 3,873
  • 4
  • 8
  • 28