+ 1

Can anyone please tell me what is wrong with below code

x = input() print(x) x += 3 print(x)

16th Dec 2018, 4:12 AM
Prabuddh Bhatia
Prabuddh Bhatia - avatar
5 ответов
+ 14
input() always takes a string so you need to typecast it to int for x+=3 to work. Check out my code below. https://code.sololearn.com/ci4X0V5KR757/?ref=app
16th Dec 2018, 4:28 AM
Lambda_Driver
Lambda_Driver - avatar
+ 9
In other words just change your first line to x = int(input())
16th Dec 2018, 5:33 AM
David Ashton
David Ashton - avatar
+ 4
thanks
16th Dec 2018, 4:37 AM
Prabuddh Bhatia
Prabuddh Bhatia - avatar
0
input takes string as input
18th Dec 2018, 5:53 PM
Mritunjay Pandey
Mritunjay Pandey - avatar
0
Thanks
23rd Dec 2018, 6:22 AM
Jermaine Anthony Gordon
Jermaine Anthony Gordon - avatar