Strings (Python)
Naar navigatie springen
Naar zoeken springen
Dit hoofdstuk gaat over dit soort objecten:
>>> a="blub" >>> type(a) <class 'str'>
Concatenate
>>> a="hoi" >>> b="hallo" >>> c=a+b >>> print(c) hoihallo >>> type(c) <class 'str'>
Zie ook Print (Python)
Replace
>>> 'Hello world'.replace('world', 'Guido')
Dubbele spaties verwijderen, lijkt gecompliceerder te liggen. Gelukkig werkt dit ook:
sentence = ' hello apple' " ".join(sentence.split())