Python Introducing Lists Using Lists Mutability

Marcos Duran
seal-mask
.a{fill-rule:evenodd;}techdegree
Marcos Duran
Python Development Techdegree Student 1,930 Points

Bringing together strings and variables with '+' vs ','

I have a question about putting together strings and variables using operands and commas.

In the previous quiz the output was correct using:

print("* ", continent) which outputed "* Asia" but the quiz did not accept. print("* " + continent) which outputed the same thing and was accepted.

At a deeper level what are the differences or limitations between these two?

2 Answers

They both have different nature and they are not the same the comma makes it a tuple and + operand just concatenates it. try this

name = "Marcos"
a = "* " , name

b = "* " + name

print(a)
print(b)

print(len(a))

print(len(b))

also try this

help(a)

help(b)

the a will be stored as a tuple and the b will be more like a single string.