4.3 (Steps 7-8)

I tried printing using plus signs as below, but I kept getting error messages (which is strange, because this method has been working for me up until now for some reason!)

print("The biggest number in " + numberList + “is” + biggestNum + “.”)

I noticed in the example we used commas, so making that simple change made it work.

print("The biggest number in ", numberList, “is”, biggestNum, “.”)

My big question is why did the plus signs work before but not in this example?

UPDATE: I found out that the + sign can only be used when concatenating strings. I used the string function str() to convert my integer to a string for the print.

1 Like

Glad that you figured this out! To provide a bit more detail, what is happening when you use print with several parameters separated by commas, the function will attempt to convert each parameter to a string (raising an error if that’s not possible). But when you try to create a new string via concatenation (with +) all of the parameters must be strings.

Thank you for the clarification, Chris!