Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 623 Bytes

File metadata and controls

42 lines (34 loc) · 623 Bytes

🐍 Basics-Strings

Alle Zeichen in einem String großmachen

text = "Hello World"
x = text.upper()
print(x)

# Output: HELLO WORLD

Alle Zeichen in einem String kleinmachen

text = "HELLO WORLD"
x = text.lower()
print(x)

# Output: hello world

Zeichen in einem String ersetzen

text = "Hello World"
txt = text.replace("H", "J")
print(txt)

# Output: Jello World

Am Anfang und am Ende werden die Leerzeichen entfernt

text = " Hello World "
x = text.strip()
print(x)

Ausgabe von-bis Zeichen aus einem String

x = "Hallo"
print(x[2:5])
# Output: llo