Skip to content

Instantly share code, notes, and snippets.



Last active Dec 25, 2019
What would you like to do?
Different line joinings in pyton
def output():
# explicit line joining with backslash (prefered for simple strings)
print("let's do some calculations \
of the body mass index")
# explicit line joining with operator # generally prefered, allows to keep indentation consistent
# PEP 8 recommends operator on the next line
print(f"weight: 75, size: 1.77 "
+ f"bmi: {bmi_calc(75,1.77)}")
# implicit line joining
# Expressions in parentheses, square brackets or curly braces
# can be split over more than one physical line without using backslashes
def bmi_calc(weight,
return weight / height**2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment