0

Hi I am very new to Python and I have been learning to create a Blackjack game. I want to print the cards on the same row, instead of on a new line each time. How should I go about doing this?

[Current Output] [1]: https://i.stack.imgur.com/B7ELY.png

Code for output is below:

def show(self):
  print('┌───────┐')
  print(f'| {self.value:<2}    |')
  print('|       |')
  print(f'|   {self.suit}   |')
  print('|       |')
  print(f'|    {self.value:>2} |')
  print('└───────┘')

1 Answers1

0

By default Python‘s print() function ends with a newline. A programmer with C/C++ background may wonder how to print without a newline. Python’s print() function comes with a parameter called ‘end‘. By default, the value of this parameter is ‘\n’, i.e. the new line character.

print("This line will be", end = ' ')
print("printed in same line", end= ' ')
kehsihba19
  • 83
  • 6