Computer Science, asked by thomasphilipt3162, 11 months ago

Write a python script that traverses through an input string and prints its character in different lines two characters per line

Answers

Answered by MoonGurl01
84

inputString = input("Please type your string: ")

i = 0

while i < len(inputString):

print(inputString[i] + inputString[i + 1])

if((i + 3) == len(inputString)):

print(inputString[i + 2])

break

i = i + 2

Depending on the console running the program, you may need to add "\n" to the beginning of the print statements so that the read print("\n" + inputString[i] + inputString[i + 1]) and print("\n" + inputString[i + 2])

Answered by AskewTronics
3

Below are the code in python for the above problem:-

Explanation:

string = input("Enter the string") # it is used to take inputs from the user.

for x in string: # for loop to print the character.

print(x) # print statement to print the character.

Output :

  • If the user inputs "hell" then all the character of the "hell" is printed one by one giving one line space.

Code Explanation:

  • The above program is in python code.
  • The first line of the code is used to render the message to the user for inputs and take the input of the user and store the value on the string variable.
  • The second line of the program is a for loop which scans all the character one by one and render it by the print statement.

Learn more:

  • Python program : https://brainly.in/question/5558161

Similar questions