Skip to content

Instantly share code, notes, and snippets.

@richellyitalo
Last active April 18, 2021 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richellyitalo/c0e1016f550e2f753258ae92ca917092 to your computer and use it in GitHub Desktop.
Save richellyitalo/c0e1016f550e2f753258ae92ca917092 to your computer and use it in GitHub Desktop.

1 - Format

string_in_string = "Shepherd {} is on duty.".format(shepherd)
print(string_in_string)
# saída = Shepherd Mary is on duty.

1.1 - Brackets

age = 32
stuff_in_string = "Shepherd {} is {} years old.".format(shepherd, age)
print(stuff_in_string)
# saída = Shepherd Mary is 32 years old.

1.2 - Formatando números

#saída --> 'Here is a 3.33333 float

2 - f-string (APENAS python 3.6+)

age = 34
stuff_in_string = f"Shepherd {shepherd} is {age} years old."
print(stuff_in_string)
#Shepherd Martha is 34 years old.

3 - Old school

print(stuff_in_string)
Shepherd Martha is 34 years old.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment