Debugging:
for i in range(10):
print(card_number[0]) # notice this line
It prints the 0th
element, that is A
in the list for 10
times, certainly not what you intended.
Hence:
Use the counter variable i
instead of the index value 0
:
card_number = ['A','2','3','4','5','6','7','8','9','10']
for i in range(len(card_number)): # Use len(card_number) instead to avoid accidents
print(card_number[i], end = " ")
Suggested (one-liner):
Using in
operator, that works for each element in the list.
print(', '.join([elem for elem in card_number]))
OUTPUT:
A, 2, 3, 4, 5, 6, 7, 8, 9, 10