0

Why is that a syntax error?

>>> print("ist kleiner als") ist kleiner als >>> x=1 >>> y=2 >>> print(x "ist kleiner als" y) SyntaxError: invalid syntax

13th Jul 2018, 10:09 AM
Michael Jedtke
Michael Jedtke - avatar
9 Antworten
+ 1
You need to use comma for concatenation.
13th Jul 2018, 10:17 AM
Akib
Akib - avatar
+ 3
you have to do print(x, "ist kleiner als" , y) or something like print(x + " ist kleiner als " + y) Comma(,) will leave a space but plus(+) will not. You can use either.
13th Jul 2018, 10:14 AM
Satyam
+ 1
wait Akib Reza only plus is used for concatenation right? not comma? or did i mess up?
13th Jul 2018, 10:24 AM
Satyam
+ 1
Thanks I think that wil be teached later in the course I tried to do some excercise and this error was very annoying
13th Jul 2018, 10:27 AM
Michael Jedtke
Michael Jedtke - avatar
+ 1
Michael Jedtke welcome. It is taught in module 1 lesson 8.
13th Jul 2018, 10:28 AM
Satyam
+ 1
S. C. oh, i don't know the correct term for this operation. Sorry.
13th Jul 2018, 10:33 AM
Akib
Akib - avatar
+ 1
same
13th Jul 2018, 10:34 AM
Satyam
+ 1
hmmm..
13th Jul 2018, 10:36 AM
Satyam
0
I just know it for some reason. String concatenation uses plus sign in python. JS uses plus sign for mentioned problem and also concatenation i think.
13th Jul 2018, 10:35 AM
Akib
Akib - avatar