Advertisement
Felanpro

Convert str to int

Mar 1st, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.19 KB | None | 0 0
  1. apples = input('How many apples do you want? ')
  2. print(int(apples) + 1)
  3.  
  4.  
  5. In python you cannot add a number to a string, instead you have to convert the string variable to an integer(int).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement