Python Forum
How to print string multiple times on new line
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to print string multiple times on new line
#7
In spoken language: "print string four times separated with newline"

Translation into Python:

name = 'Guido'
age = '64'
message = f'Hello {name}! You will be 100 years old in {2020 + (100 - int(age))}'
print('\n'.join(message for i in range(4)))
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: How to print string multiple times on new line - by perfringo - Sep-30-2020, 01:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with spliting line in print akbarza 3 425 Jan-23-2024, 04:11 PM
Last Post: deanhystad
  splitting file into multiple files by searching for string AlphaInc 2 919 Jul-01-2023, 10:35 PM
Last Post: Pedroski55
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 12,635 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  Trying to loop through code to plot seaborn line plots across multiple subplots eyavuz21 0 1,706 Dec-05-2022, 10:46 AM
Last Post: eyavuz21
  Print the line before the corrent line tester_V 9 1,591 Nov-18-2022, 08:39 AM
Last Post: Gribouillis
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,405 Sep-27-2022, 01:38 PM
Last Post: buran
  Remove a space between a string and variable in print sie 5 1,829 Jul-27-2022, 02:36 PM
Last Post: deanhystad
  Inserting line feeds and comments into a beautifulsoup string arbiel 1 1,210 Jul-20-2022, 09:05 AM
Last Post: arbiel
  Matching multiple parts in string fozz 31 6,427 Jun-13-2022, 09:38 AM
Last Post: fozz
  Can you print a string variable to printer hammer 2 1,986 Apr-30-2022, 11:48 PM
Last Post: hammer

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020