'Python, print string on the same line for screen output

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



Solution 1:[1]

you could try to do it like this:

print(card*5)

Solution 2:[2]

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

Solution 3:[3]

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--

Solution 4:[4]

As a possible answer:

card = "--Diamonds--"
result = card + card + card + card + card
print(result)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Austin He
Solution 2 Monocorn
Solution 3
Solution 4 Tkun