189k views
0 votes
Create a Python program that will produce the following output:

Given the following sentence, print out

every third letter.
The Python programming language makes manipulating strings very easy!

User LudoC
by
5.7k points

1 Answer

4 votes

Answer:

def main ():

sentence = input("Please enter a sentence:")

print("Original Sentence:",sentence)

# start at the third character

for i in range(2, len(sentence), 3):

# access the string by index

print("Every third letter:", sentence[i])

Step-by-step explanation:

def helps define the sentence ( input)

in order to start printing from third letter we start the range from 2 and keep the step 3 . The range i is in square parenthesis to show the range and access string.

User John Fisher
by
5.8k points