Please help with Lens Slice Challenge! Why do I get this type error?

![Screen Shot 2022-12-08 at 11.23.50 AM|690x431](upload://kV


Why is that when I have just print("We sell " + str(num_pizza) I get part of the needed output (W sell # different types of pizza!) but when I attempt to add the next needed part? Thanks in advance

Online 9, “different kinds of pizza!” is outside of the print function.

It should be:

print('We sell ' + str(num_pizzas) + 'different kinds of pizza!')

Let me know if this resolves your issue!


Yes thank you seraph, I had to remove one of the parentheses from the num_pizzas list and close the print statement. seems like is always the smallest adjustments that throws the code off, thank you again.

Can anyone please explain why num_pizzas works here too despite not being converted into a string?

print("We sell", num_pizzas, "different kinds of pizza!")

It works because it is a comma separated list, akin to a tuple which can be heterogeneous (having mixed types). This a non-standard approach to printing mixed data types without the need to re-cast to str type.

Personally, I wouldn’t make a habit of using that format for printing. Better if it is all one type, in this case, str.

print (f"We sell {num_pizzas} different kinds of pizza!")

Note that above we used the newest form of output formatting, the f-string.

1 Like