input from user

前端 未结 4 1014
耶瑟儿~
耶瑟儿~ 2021-01-23 04:45

It\'s a very basic doubt in Python in getting user input, does Python takes any input as string and to use it for calculation we have to change it to integer or what? In the fol

4条回答
  •  失恋的感觉
    2021-01-23 05:15

    raw_input() stores the inputted string from user as a "string format" after stripping the trailing new line character (when you hit enter). You are using mathematical operations on string format that's why getting these errors, first cast your input string into some int variable by using a = int(a) and b = int(b) then apply these operations.

提交回复
热议问题