Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Fall 2006 Midterm 2 Review: List Output

Post your questions here.

This function will output:
The string is cHEcK
The list is ['1','H','E','7','K']

David Poore

Right - Bobby Mathew

could someone explain...I do not understand this.

At first you have an empty list. The first for loop adds items to your list starting at 1 and going up 11. It also skips every other number. So now your lists is [1,3,5,7,9]. Now you are given a string "cHEcK". The for loop has us loop through the length of this string. Whenever one of indexes in the string is uppercase, the index in the original list is replaced with the index from the string. So for example, c (which is at index value 0), is lowercase so it is skipped. H, at index value 1, is uppercase. So list[1] = string[1], or 3 = H. So the 3 is replaced with an H in the original list. When all is said and done, you are left with the answers above. I'm not sure if I am 100% correct on my terminology, but that's the best I can do to describe what is happening.

Great explaination. -Brittany Duncan



Link to this Page