+ 1
I don't understand the concatenation here in this string. Please help me understand.
Let's say you want to print something like "John [Smith] is a coder." first = 'John' last = 'Smith' message = 'first + ' [' + last + '] is a coder' print(message)
7 Respostas
+ 2
Thanks so much for solution guys.
+ 1
What specifically?
0
The main problem is that there was a mistake with using the quotes:
# Missing a quote?
# v
'first + ' [' + last + '] is a coder'
But you might be interested in the format method, supports performing string concatenations much easier:
message = '{0} [{1}] is a coder'.format(first, last)
0
Okay I get it. What I don't quite understand is line 4 on the variable message.
0
The problem is, that between 'first +' and ' [' were not performed a string concatenation, because + was outside the string. Propably just a typing/thinking mistake
0
I don't get it because I just began. I'm really bad at coding. I shouldn't be replying. sorry.