0
use of symbols between single qoutes
print ('1'+'2'+'3') fetches me 123 as output but print ('1'-'2'-'3') gives me an error. can i know why ??
8 Antworten
+ 4
Hi! Because you are trying to subtract a string from a string. Like this: "Bob" - "Martin"= ?
please, take a closer look at the Python tutorial, which explains operations with strings
+ 5
'str1' + 'str2' concats the two strings so that it gives 'str1str2'
but the - operator is not defined for strings.
if you want to operate with the numeric value of a string str, use int(str) instead.
+ 1
because in a string operation, plus doesn't work as an arithmetic addition sign. it is a command built into the language in order to glue the two strings together. but how do you imagine a reverse operation? it doesn't exist.
+ 1
Please, see more carefully this tutorial:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2427/
+ 1
Ярослав Вернигора(Yaroslav Vernigora)
I'm still in Mod 1. I think I will learn this on the way. Sorry, I was bit too curious
0
John Robotane
I'm new to coding .
But what you said makes sense, but I couldn't catch up.
Gimme some examples so I can understand.
0
Ярослав Вернигора(Yaroslav Vernigora)
Thanks for the answer
Actually I'm new to coding so how "bob"+"Martin" works
And
"Bob"-"Martin" doesn't work
0
You are welcome! you are absolutely right! you will soon find out for yourself. by learning the lessons step by step. but I have already opened the veil of this mystery to you... 😉