How do you break a long single-line method call to multiple lines?
Experience Level: Junior
Tags: Python
Answer
When calling a method, the arguments can be broken to multiple lines because they are between brackets.
Example:
def do_something(name: str, age: int, nick: str):
print(f"{name} {age} {nick}")
do_something(
name="John Doe",
age=78,
nick="Frog")
Related Python job interview questions
What does strptime stand for?
Python JuniorHow do you convert string to a strongly-typed datetime in Python?
Python JuniorHow do you split long method signature to multiple lines in the most efficient way?
Python JuniorHow do you split long line to multiple lines in Python?
Python JuniorWhat does self do in Python?
Python Junior