-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
  • 112,593
  • 23
  • 157
  • 280
Mario
  • 177
  • 2
  • 2
  • 9

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
  • 8,161
  • 2
  • 12
  • 24