Back to marketplace

Python String Functions (UC-Wk 2)

No description yet. This curated deck is ready for daily study.

Total cards: 8•Content version: v3•Public deck•Updated: 8/1/2026

Card preview (8)

#1
Front (Question)

String method to remove leading and trailing white spaces

Back (Answer)

str.strip()

#2
Front (Question)

How to remove other leading or trailing characters (non whitespace) from string

Back (Answer)

str.strip(“*”) removes leading / trailing asterisk

#3
Front (Question)

Split out words that are separated by a char in a string (eg, a white space or comma”

Back (Answer)

s.split(‘ ‘) or s.split(‘,’) (or any char)

#4
Front (Question)

How to slice strings (sub-set) with lists

Back (Answer)

list = ‘Hello’; list[1:3] gives chars indexed to position 1 and 2 (3 is excl)

#5
Front (Question)

Check to see if substring (‘He”) is in the substring ‘Hello’

Back (Answer)

‘He’ in stringVar (where stringVar = ‘Hello’)

#6
Front (Question)

Get the index of where a substring starts in a string (eg, ‘el’ in ‘Hello’)

Back (Answer)

word.find(‘el’) (returns 1)

#7
Front (Question)

ex. insert Bob and Joe into string = ‘Jane Jill’

Back (Answer)

string2 = ‘Jane Jill { } { } ‘; string2.format(‘Bob’, ‘Joe’)

#8
Front (Question)

specify where you want to insert strings into a string using format function

Back (Answer)

str = ‘I love {1} and{0}’ ; allows you to re-arrange the strings you’re inserting