a= input (“enter a number”)
But in output , after enter a number , I’m unable to write anything
My input function is not working
( I use vs code )
You can use format strings in your print statement, like this.
a = input("Enter a number:")
print(f"Your number was {a}")
print("Your number was " + str(a)) # Or do this but you must convert a to string first.
In VS Code the output terminal would normally show when you run the program. So loo for the output terminal below your code window.
Hi,
if you want an actual number, first determine what kind of number that you are expecting. Will it be a type float
(includes decimal numbers) or a type int
(integer)? Note that by default, the input
keyword only provides type str
strings.
To typecast the input, you can do any of the following:
a= int(input (“enter a number”)) # for integer type
or
a= float(input (“enter a number”)) # for float type
Or of course:
print("Your number was", a)
because print()
converts every argument to a string before printing
it.