"joe"[0]
"j"
What does it mean to be immutable
Cannot be changed. If you want to make a change you need a new variable or to lose the old value
What are the two ways you can iterate over a loop?
By element or character
By index or range
Which method checks for extra spaces at the start and end?
.strip()
How do you change a value into a string
str(variable)
"Sarah"[1:4]
"ara"
"abc" in "abc"
True
Write the two loop headers for the two ways of writing a loop with a string. Assume the variable "name" is a string.
for letter in name:
for i in range(len(name)):
What does swapcase do?
uppercase letters become lowercase letters
lowercase letters become uppercase letters
numbers and characters stay the same
How do you identify a string?
" " or ' '
"Joseph"[100]
error
"abc" in "A"
False
word = "sad"
for x in range(len(word)):
print(str(x)+ word[x])
Index concatenated with the character
0s
1a
2d
What is the difference between a and b?
a.find(b)
len("abcdefg")
"Mazen"[1:100]
"azen"
"ace" in "abcefgh"
Falsse
word = "abcdefg"
for letter in word:
if letter in "abc":
print(1)
else:
print(letter)
if letters a, b, or c, print 1 otherwise print the letter
1
1
1
d
e
f
g
"a".swapcase().lower().upper().islower()
False
Why is user input being a string beneficial?
- math, into a number, try except
- words, change capitalization, loop to check
"abcdefghijklmnop"[5:][1]
"g"
"hi"[0] = "H" produces an error
loop through the string "hello". If there is a vowel, print the index, otherwise print the letter
x = "hello"
for i in range(len(x)):
if x[i] in "aeiou":
print(i)
else:
print(x[i])
When would you use .isupper() and not .upper()
Checking if uppercase, and want to use in an if statement
How do you add a new line or tab in your string?
/n new line
/t tab