Python For Loop Exercises
Let’s check out some exercises that will help you understand Python’s For Loops better.
Write a for loop so that every item in the list is printed.
Write a for loop which print "Hello!, " plus each name in the list. i.e.: "Hello!, Sam"
Write a for loop that iterates through a string and prints every letter.
Type a code inside the for loop so that counter variable named c is increased by one each time loop iterates. Can you guess how many times it will add 1?.
Using a for loop and .append() method append each item with a Dr. prefix to the lst.
Write a for loop which appends the square of each number to the new list.
Write a for loop using an if statement, that appends each number to the new list if it's positive.
Using for loop and if statement, append the value minus 1000 for each key to the new list if the value is above 1000. i.e.: if the value is 1500, 500 should be added to the new list.
Write a for loop which appends the type of each element in the first list to the second list.