0

Somebody wrote code to take a string input and output it, repeated 10 times. However, the code results in an error.

How can I solve it because this was given X=input() Print (x +10) While the output is hellohellohellohellohellohellohellohellohellohello

29th Aug 2021, 8:02 PM
Oti Stephen
Oti Stephen - avatar
2 ответов
+ 9
You cannot add number with string. It will give error. Use * instead of +
29th Aug 2021, 8:15 PM
A͢J
A͢J - avatar
+ 1
x = "3" print(x+3) >>>Output: TypeError ( string and integer cannot be added) x = int(3) print(x+3) >>>Output: 6 x = "3" print(x*10) >>>Output: 3333333333 x = int(3) print(x*10) >>>Output: 30
30th Aug 2021, 12:53 AM
Sacar
Sacar - avatar