CGSC 1005 Lecture Notes - Lecture 8: American Broadcasting Company

35 views2 pages

Document Summary

We can access individual elements of a sequence. [ ] is the python operator that allows this. The argument to the operator must be an integer and must be between 0 and one less than the string length (we can actually use negative indexes too but we will not for this class) Is the error you will get if your selected element is outside of the range of characters in the string. The function len( ) gives us the number of elements in a sequence. This is a program that will print out the characters of the string one by one. The program below counts the number of a letters. The changing or modifying of the contents of strings cannot be done. You can create an existing string based off of the original string len_str1 = len(str1) print(len_str1) name = kathy name [0] = c . One way to repeat code is via a while loop.

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