informatica python functions noortje

String functies

Er zijn veel verschillende string functies die we kunnen gebruiken:

str.find(substr) Zoeken naar een substring str.replace(old, new) Vervanging van een substring str.split(delim) Splitsen op basis van een teken str.join(seq) Plakken van strings
str.strip( ) Verwijderen van enters/nieuwe regels str.rstrip( ) Verwijderen van spaties rechts

Capital letters

.upper() makes all letters in a string uppercase

.lower() makes all letters in a string lowercase

.capitalize() will capitalize the first letter of a string

Toetsing

str.isupper( ) Toetsen of een string uit hoofdletters bestaat

str.isdigit( ) Toetsen of een string uit cijfers bestaat
*if its a digit it will return True if its not a digit it returns False

str.isalpha() Toetsen of een string cijfers bevat if its only alphabetical characters it will return True if its not only alphabetical characters it will return False (this includes spaces)