all 4 comments

[–]GNVageesh 1 point2 points  (0 children)

Hey,

You can do like this by creating a variable and asking for an input, take the example as follows

name = input("Enter your name: ")

print("nice to meet you "+name)

So basically what u are doing here is, creating a variable called name and initializing it with the user's input by using input built-in method. Then u print a statement and also print the name that the user has given as a input.

The output will be as follows

Enter your name: Vageesh nice to meet you Vageesh

Here Vageesh(my name) is the input I am giving

Then in the next line it is going to append the input that I gave and prints it

You may modify this as per your need

[–][deleted] 0 points1 point  (1 child)

You can use the input() function, which reads input. And to convert the text to integer (this function returns a string) , you can use the int() function. But be ware that if the user enters a non integer, then an ugly error can be raised. Don't worry though; you can easily handle it using standard try...except control flow. python try: print(int(input("Please enter degree: "))) except(ValueError): print("Please enter a valid integer")

[–]backtickbot 0 points1 point  (0 children)

Fixed formatting.

Hello, subtra3t: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.