Months_not_minutes
Months_not_minutes

Reputation: 35

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

Upvotes: 2

Views: 163

Answers (4)

Tkun
Tkun

Reputation: 69

As a possible answer:

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

Upvotes: 1

Laser
Laser

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

Austin He
Austin He

Reputation: 131

you could try to do it like this:

print(card*5)

Upvotes: 4

Monocorn
Monocorn

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

Related Questions