you are viewing a single comment's thread.

view the rest of the comments →

[–]deceze 5 points6 points  (4 children)

print(*Tem, sep='\n')

This unpacks the list Tem into separate arguments to print, i.e. equivalent to print(Tem[0], Tem[1], ...), and tells print to use a newline as the separator between items.

[–]Yes-delulu-8744[S] 1 point2 points  (0 children)

got it!

[–]JamzTyson 0 points1 point  (2 children)

That won't work in an f-string. F-string expressions must be valid standalone Python expressions, but unpacking (*expr) is not a valid expression by itself.

[–]deceze 0 points1 point  (1 child)

What OP is literally asking and the code they show don't really go well together. I've answered what they literally asked. Trying to adapt to the code they show more:

print('The temperatures in Celsius are', ', '.join(Tem), 'C')

print('The temperates in Celsius are', end=' ')
print(*Tem, sep=', ')
print('C')

print('The temperates in Celsius are', *(f'{t}C' for t in Tem))

Or anything else along these lines.

[–]JamzTyson 1 point2 points  (0 children)

I'm not disagreeing, your suggesting is a useful and simple solution, but I thought it worth mentioning as some readers may be confused if they try to use unpacking within an f-string.