Tipi di dati in Python
Jason Myers
Instructor
f""cookie_name = "Anzac"
cookie_price = "$1.99"
print(f"Each { cookie_name } cookie costs { cookie_price }.")
"Each Anzac cookie costs $1.99."
"".join() usa la stringa su cui è chiamato per unire un iterabilechild_ages = ["3", "4", "7", "8"]
print(", ".join(child_ages))
"3, 4, 7, 8"
print(f"The children are ages {','.join(child_ages[0:3])}, and {child_ages[-1]}.")
"The children are ages 3, 4, 7, and 8."
.startswith() e .endswith() indicano se una stringa inizia o finisce con un certo carattere o stringaboy_names = ["Mohamed", "Youssef", "Ahmed"]
print([name for name in boy_names if name.startswith('A')])
["Ahmed"]
in cerca un valore in un iterabile come una stringa."long" in "Life is a long lesson in humility."
True
"life" in "Life is a long lesson in humility."
False
.lower() restituisce la stringa in minuscolo"life" in "Life is a long lesson in humility.".lower()
True
Tipi di dati in Python