I can't remember where I saw this but I don't understand what's going on here. What use does print(*x)
provide?
The following code:
x = [(1, 2), (3, 4)]
print(x)
print(*x)
y = [1, 2, 3, 4]
print(y)
print(*y)
z = 1, 2, 3, 4
print(z)
print(*z)
Gives the following output:
[(1, 2), (3, 4)]
(1, 2) (3, 4)
[1, 2, 3, 4]
1 2 3 4
(1, 2, 3, 4)
1 2 3 4
I see what is happening but I don't know what is happening. In the previous cases, it just outputs them without any brackets or commas. But when I use this with a dictionary:
a = {1: "a", 2: [1, 2, 3], 3: (4, 5, 6)}
print(a)
print(*a)
I only get the keys back with the second print:
{1: 'a', 2: [1, 2, 3], 3: (4, 5, 6)}
1 2 3