Answers for "howto prety print list in python"

4

python print dict pretty

>>> import json
>>> print json.dumps({'a':2, 'b':{'x':3, 'y':{'t1': 4, 't2':5}}},
...                  sort_keys=True, indent=4)
{
    "a": 2,
    "b": {
        "x": 3,
        "y": {
            "t1": 4,
            "t2": 5
        }
    }
}
Posted by: Guest on November-25-2020
0

how to print a list nicely python

# Creating a list. Can also be floats and intagers
list = ["a", "b", "c", "d", "e", "f", "g"]

# Have a for loop and then print the answer index of the variable in the loop(i)
for i in range(len(list)):
    print(list[i])

# Output
a
b
c
d
e
f
g
Posted by: Guest on January-17-2021

Python Answers by Framework

Browse Popular Code Answers by Language