CSC108H5 Lecture Notes - Lecture 6: Substring, For Loop, Pineapple

46 views5 pages
School
Course
897wjface and 39475 others unlocked
CSC108H5 Full Course Notes
12
CSC108H5 Full Course Notes
Verified Note
12 documents

Document Summary

File "", line 1, in x + 3. Typeerror: can"t convert "int" object to str implicitly. >>> while (i < len(s) - 1): print(s[i]) i += 1 h e l l. # i have to go up until len(s): >>> while (i < len(s)): print(s[i]) i += 1 h e l l o. >>> for char in s: print(char) h e l l o. >>> for char in ["h", "e", "l", "l", "o"]: print(char) h e l l o. # for loop goes through a sequence of items one by one: >>> for i in [0, 1, 2, 3]: print(i) >>> while (i < 4): print(i) i += 1. # what if i wanted to print out a substring, one character at a time, # using a for loop? e. g. the "apple" part of "pineapple" # one way to do this is pass in two values to range (beginning, end-1):

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions