You can format what is printed. I like this as it gives me total control.
This is a bit of code I extracted from a tic-tac-toe game. In uses str formatting and str joining to print out the tic-tac-toe board.
x, y = 5, 6 print(f"My numbers are ({x},{y})")
Output:My numbers are (5,6)
As for printing multiple prints on one line, you can do that with stdout.write() and print(end=""), but I prefer not doing multiple prints.This is a bit of code I extracted from a tic-tac-toe game. In uses str formatting and str joining to print out the tic-tac-toe board.
class Board(): def __init__(self, board): self.board = list(board) def __str__(self): rows = [f" {self.board[i]} | {self.board[i+1]} | {self.board[i+2]}" for i in range(0, 9, 3)] return "\n---+---+---\n".join(rows) winner = "O" ttt = Board("OX OXX O") print(f" The winner is {winner}\n\n{ttt}")
Output:The winner is O
O | X |
---+---+---
| O | X
---+---+---
X | | O
By making the entire board a str it is easy to ask the where to place the next "X".pos = input(f"{board}\n {player}: ")
Yoriz write Feb-11-2022, 06:29 AM:
Note the post that this post was replying to has been removed, it was a post of someone that had bumped an old post to show a link advertising a website.
The spammer has been purged.
Note the post that this post was replying to has been removed, it was a post of someone that had bumped an old post to show a link advertising a website.
The spammer has been purged.