0
Adding a string to a number produces an error. Please give an example to illustrate it.
6 Respostas
+ 4
we can't add strings with numbers because they both have different data types.
But you can do by converting an integer into a string then add with strings.
x=3
y="hello"
print(str(x)+y) #output=3hello
+ 2
Sharad Kumar Mishra sorry I edit my answer due to fast typing I write int(x) in print but it should be str(x)
0
Maninder $ingh but I have tried it you can also try by coding following code:
print("7"+'string')
0
Maninder $ingh this wasn't my question but you are right in your way of understanding
0
Jan Markus thank you. Since I am begginner therefore I also have some minor confusion
0
Jan Markus I am not saying to you I am saying to Maninder $ingh