CMPT 120 Lecture Notes - Lecture 11: Peter Jackson

14 views1 pages
meghan78 and 39786 others unlocked
CMPT 120 Full Course Notes
29
CMPT 120 Full Course Notes
Verified Note
29 documents

Document Summary

Lecture 11: strings, lists, and control structures: while. >>> sentence = my name is peter robert jackson! split() function is used to parse or break a long string into words or parts. >>> words = "my name is peter robert jackson! 5 print(words) len(words) print(words[3]) words = ["my", "name", "is", "peter", "robert", "jackson!"] The variable words in this case refer to group of values (i. e. , not a single value. ) So, the split() function creates a list. List: is an object that contains multiple data items. Values in a list can be accessed using an index. By default, the split method uses spaces as separators (that is, it returns a list of the words in the string that are separated by spaces). You can specify a different separator by passing it as an argument.

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