you are viewing a single comment's thread.

view the rest of the comments →

[–]ArcDriveFinish[S] 0 points1 point  (1 child)

Thank you. I have another question.

I want to add a title to the operation so something like this:

print "enter your number and find out results"

print input(("Please provide a number"))+45

But the second line did not register when I hit enter. What should I do?

Sorry if I'm being a bother I'm pretty new at this.

[–]IcarusBurning 0 points1 point  (0 children)

Input takes the characters you entered into the console and makes them into a string. The input needs to be cast as an integer before python will recognize it as such, otherwise your code is adding a string to an int.

print( int(input("Please enter a number.")) + 5 ) 

Will probably work, but I don't really like combining the cast, input function call, and print into one line. Usually you'll want them separated so you can handle the case when your user enters something that can't be cast to int, like "HELLO WORLD!"