Reputation: 35
I am lost on printing a character on the same line.
For example
card = "--Diamonds--"
Output needed: --Diamonds-- --Diamonds-- --Diamonds-- --Diamonds-- --Diamonds--
The same string variable (not a list) to be repeated on a single line. I don't want it to be a list at this stage, just an image for visuals.
Cheers
Upvotes: 2
Views: 163
Reputation: 69
As a possible answer:
card = "--Diamonds--"
result = card + card + card + card + card
print(result)
Upvotes: 1
Reputation: 46
This also works:
card = "--Diamonds--"
for i in range(1, 6):
print(card, end=' ')
This would output:
--Diamonds-- --Diamonds-- --Diamonds-- --Diamonds-- --Diamonds--
If you want there to be no spaces in between the words, you need to use:
card = "--Diamonds--"
for i in range(1, 6):
print(card, end='')
output:
--Diamonds----Diamonds----Diamonds----Diamonds----Diamonds--
Upvotes: 2
Reputation: 41
Just do this:
card = "--Diamonds--"
print(card, card, card, card, card)
You can repeat it infitely just alway make a comma and then the variable
Upvotes: 2