-3

I want to take from the user an input integer, and turning to a string in my code. My line of code for that is:

num1 = input(int(str("Enter a number: ")))

But the console says: ValueError: invalid literal for int() with base 10: 'Enter a number: ' If this line isn't correct can you show me a way how can I turn an integer that is given by the user to a string in my code?

martineau
  • 119,623
  • 25
  • 170
  • 301
Mario
  • 301
  • 2
  • 3
  • 11

1 Answers1

1

You have the functions in the wrong order: First you need to turn the input into a Python object, so input() has to be the innermost function (to be applied first). Also, input() will cast the input as a string by default, so you don't need str().

So the line should read:

num1 = input("Enter a number: ")
Arne
  • 9,990
  • 2
  • 18
  • 28