Question: Create a for loop that iterates over names to find the name that meets the following two conditions: a) it starts with S and b)

Create a for loop that iterates over names to find the name that meets the following two conditions: a) it starts with S and b) its length is 5. The loop stops when it finds the first occurrence of the name, printing the name found along with its index position in the format "[INDEX] NAME", where INDEX is the current index position and NAME is the name found. The printed output should look as follows:

names = ["Alice", "Bob", "Mary", "Sam", "Sarah", "Tom", "Susan"]

Step by Step Solution

3.37 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Program names Alice Bob Mary Sam Sarah Tom Susan for index in ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!