I was trying to do a basic spinning animation using "\|/-" which went fine, but I wanted two on the same updating line. With one spinning clockwise and one spinning anti-clockwise.
Here is what I came up with:
animation_1 = ['\\', '|', '/', '-']
animation_2 = ['/', '|', '\\', '-']
while True:
for iteration_1, iteration_2 in animation_1, animation_2:
print(f'\r {iteration_2} {iteration_1}', end='')
sleep(.5)
sys.stdout.flush()
Which get the output:
"Traceback (most recent call last):
File "/Users/pungkrock/PycharmProjects/ans/fib.py", line 18, in <module>
for iteration_1, iteration_2 in animation_1, animation_2:
ValueError: too many values to unpack (expected 2)"
This example:
animation_1 = ['\\', '|', '/', '-']
animation_2 = ['/', '|', '\\', '-']
while True:
for iteration_1, iteration_2 in animation_1:
print(f'\r {iteration_2} {iteration_1}', end='')
sleep(.5)
sys.stdout.flush()
Gets the output:
"Traceback (most recent call last):
File "/Users/pungkrock/PycharmProjects/ans/fib.py", line 18, in <module>
for iteration_1, iteration_2 in animation_1:
ValueError: not enough values to unpack (expected 2, got 1)"
And this error massage I do understand. But I don't understand why I get an error message from the first example.
This example works fine:
animation_1 = ['\\', '|', '/', '-']
# animation_2 = ['/', '|', '\\', '-']
while True:
for iteration_1 in animation_1:
print(f'\r {iteration_1}', end='')
sleep(.5)
sys.stdout.flush()
Can some kind soul explain to me way the first code example doesn't work? Or if I'm missing some basic understanding of some concept of the language? "too many values to unpack (expected 2)", it did get 2? What am I missing?