Skip to content
Advertisement

Printing a list of tuples in a formated form with f-strings by a list comprehension

I want to print out a list of tuples in a formated form… I have the following list which contains a tuple formed by a string and other tuple of floats:

JavaScript

I have the following code

JavaScript

However it is causing a error such as

JavaScript

I need to print them as follows: print the first element of the tuple, then for each float of the second element print them out whith the format function

I would like it to be printed using the list comprehension… For the dalta sample it should output the data down bellow

JavaScript

Advertisement

Answer

JavaScript

Prints:

JavaScript

If you want to call your format function:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement