Home > other >  how to hide curly bracket while printing in python
how to hide curly bracket while printing in python

Time:10-16

gameFound = 1
gameCount = 4
text = (gameFound,'Out of',gameCount,'games matched the search')

print(text)

I want to display like the following output without {},[] '' 1 Out of 4 games matched the search.

CodePudding user response:

Right now you're creating a tuple, that will never print cleanly. Use an f-string to create a single string, that's what it's meant for.

text = f'{gameFound} Out of {gameCount} games matched the search'

CodePudding user response:

You can use " ".join() to join the whole text together at once.

text = ' '.join([str(gameFound), "Out of", str(gameCount), "games matched the search"])

The code should be:

gameFound = 1
gameCount = 4

text = ' '.join([str(gameFound), "Out of", str(gameCount), "games matched the search"])

print(text)

For more detail, visit this website.

  • Related