Python Forum
Print characters in a single line rather than one at a time
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print characters in a single line rather than one at a time
#1
 
for x in range(len(s)):
    if x % 2!=0:
        print(s[x])
This is the code I am using to print every other character in a string. However, when I run it, it prints the characters like this:
a
b
c
d
How can I get it to print them in a single line?(ex. abcd)
Reply


Messages In This Thread
Print characters in a single line rather than one at a time - by hhydration - Oct-10-2020, 09:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Presenting multiline data into single line aaronbuhu 1 372 Aug-05-2021, 10:57 AM
Last Post: jamesaarr
  How to print results of asyncio websockets at the same time? codingmonster 0 558 Jun-04-2021, 01:48 PM
Last Post: codingmonster
  beginner text formatting single line to column jafrost 4 1,196 Apr-28-2021, 07:03 PM
Last Post: jafrost
  If match not found print last line tester_V 2 1,110 Apr-26-2021, 05:18 AM
Last Post: tester_V
  Read characters of line and return positions Gizzmo28 2 695 Nov-04-2020, 09:27 AM
Last Post: perfringo
  print a line break in writelines() method leodavinci1990 1 1,061 Oct-12-2020, 06:36 AM
Last Post: DeaD_EyE
  How to print n days back date at give time Mekala 1 738 Oct-10-2020, 03:35 AM
Last Post: bowlofred
  get two characters, count and print from a .txt file Pleiades 9 1,181 Oct-05-2020, 09:22 AM
Last Post: perfringo
  How to print string multiple times on new line ace19887 7 1,986 Sep-30-2020, 02:53 PM
Last Post: buran
  Using lambdas and map() to parse substrings in a single line Drone4four 5 1,345 Sep-20-2020, 10:38 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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