107k views
2 votes
Hi. I'm a beginner in python. Can anyone tell me what I'm missing or doing wrong, because I can't figure out why my messages in the final print aren't getting spaced out. For example in the picture that I attached, why isn't there space between "andfries".

Hi. I'm a beginner in python. Can anyone tell me what I'm missing or doing wrong, because-example-1
User DoubleDunk
by
3.7k points

1 Answer

4 votes

Answer:

message = "i hate cheese and"

message += " fries"

print(message)

Step-by-step explanation:

Whenever you do string concatenation, which is just combining strings, it doesn't put a space in between the items you're joining together, it does exactly what you tell it to do, so to add a space between the two pieces of text you would have to do the following:

```

message = "i hate cheese and"

message += " fries"

print(message)

```

Don't copy the ```, I just put that to indicate anything in between is code

Anyways notice the space I put before fries? That should also add a space in the message so there is a space between "and" and "fries"

User Kiryl Ivanou
by
3.4k points