Bottom Page

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

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  question: finding multiple strings within string djf123 4 233 May-16-2020, 01:00 PM
Last Post: snippsat
  Split string with multiple delimiters and keep the string in "groups" DreamingInsanity 4 139 May-12-2020, 09:31 AM
Last Post: DeaD_EyE
  Running Ajax multiple times on button click? CaptainCsaba 1 148 Mar-11-2020, 02:17 PM
Last Post: CaptainCsaba
  print python json dump onto multiple lines lhailey 2 3,524 Mar-02-2020, 12:47 PM
Last Post: vishalhule
  Problem with accepting multiple string inputs Ryan_Todd 5 279 Jan-22-2020, 06:12 PM
Last Post: buran
  Print 'X' a number of times Than999 1 136 Jan-18-2020, 06:41 PM
Last Post: Larz60+
  How to print the 2nd column of a searched string in a csv ptey07 2 226 Jan-11-2020, 11:25 AM
Last Post: ptey07
  Print string after decode martinzeifang 1 252 Jan-02-2020, 10:16 AM
Last Post: buran
  Phyton code to load a comma separated csv file in to a dict and then in to a dB mrsenorchuck 2 398 Nov-29-2019, 10:59 AM
Last Post: mrsenorchuck
  Print string in a single line RavCOder 8 408 Nov-08-2019, 09:45 AM
Last Post: perfringo

Forum Jump:

Users browsing this thread: 1 Guest(s)