Python Forum
How to print string multiple times separated by delimiter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to print string multiple times separated by delimiter
Is there any way to print single string multiple tiles in same line and separated by dilimiter:

print(*range(5), sep=", ") ## this is working
s = 'abcd'
print(s*2) ## this is working
print((s*2),sep=' and ') ## this is not working
It is not working because it is one string item
s = 'abcd'
print(*(s for _ in range(2)), sep=' and ')
abcd and abcd

Possibly Related Threads…
Thread Author Replies Views Last Post
  Print first day of the week as string in date format MyerzzD 2 251 Sep-29-2021, 06:43 AM
Last Post: MyerzzD
  Replace String in multiple text-files [SOLVED] AlphaInc 5 670 Aug-08-2021, 04:59 PM
Last Post: Axel_Erfurt
Question How to extract multiple text from a string? chatguy 2 661 Feb-28-2021, 07:39 AM
Last Post: bowlofred
  if a string has a digit - print tester_V 2 653 Jan-16-2021, 04:48 AM
Last Post: tester_V
  How to create new line '/n' at each delimiter in a string? MikeAW2010 3 801 Dec-15-2020, 05:21 PM
Last Post: snippsat
Question How to print multiple elements from multiple lists in a FOR loop? Gilush 6 834 Dec-02-2020, 07:50 AM
Last Post: Gilush
  How to print string multiple times on new line ace19887 7 1,901 Sep-30-2020, 02:53 PM
Last Post: buran
  convert string into multiple columns in python3 VAN 2 1,107 Sep-26-2020, 11:14 PM
Last Post: scidam
  Copy mp3 file multiple times and rename Mar10 4 1,372 Sep-23-2020, 01:09 AM
Last Post: Mar10
  print function help percentage and slash (multiple variables) leodavinci1990 3 895 Aug-10-2020, 02:51 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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