0

I have a cardgame, and I want to print it in this format:

0   1   2   3   4   5   6   7   8
2♠  6♣  10♣ Q♦  2♦  3♦  9♣  5♣  8♣
4   4   4   4   4   4   4   4   4

Currently my code is like this:

 for i in stacks:
            print(counter1)#Gives each card a number 
            print(i[-1].value, i[-1].suit)#Cards gotten out from nested list
            print(len(i), end=" ")#Tells how many cards left in the deck
counter1 += 1 #It gives each card a number. 

and the result prints it downwards. What can I do to improve? I tried sep and end, but it doesn't work the way I want it to.

Originally I had the code like this:

print(counter1, "      ",  i[-1].value, i[-1].suit, "      ", len(i))

But I'm trying to find the best solution

Im working on Python 3 Thanks for any help!

1 Answers1

0

You need 3 different for for this.

for i in stacks:
            print(counter1, end='   ')#Gives each card a number 
            counter1 += 1
print()
for i in stacks:
            print(i[-1].value, i[-1].suit,  end='  ')#Cards gotten out from nested list
print()
for i in stacks:
            print(len(i),  end='   ')#Tells how many cards left in the deck
print()
            

no746
  • 408
  • 6
  • 23