CSC108H5 Lecture Notes - Lecture 10: Empty String

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

Document Summary

# notice that this does not include s[3] # the white space counts as a character, s[4] is just the space. # notice that you can use negative indices for string slicing. # this goes from s[-3] (the third last character) to the end of the string. # this tries to go from s[-3] to s[1] but s[1] occurs before s[-3] # so we just get back an empty string. # here, we actually get something because s[9] occurs after s[-3] # also, we can get the reverse of a string by doing this. Given a number n, print out a line of dashes that has n dashes in total. # 2: for i in range(n): print("-", end="") # gets rid of the default new line after print def every_other(s): (str) -> s. "bta" new_s = "" for i in range(0, len(s), 2):

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions