Let's talk about space management: PEP 8 advises not to put spaces immediately inside…
- User
Let's talk about space management: PEP 8 advises not to put spaces immediately inside parentheses, or between a function name and the parentheses that follow it. It keeps things looking clean and organized.
Here is an example that doesn't follow the rule:
print( 'I have an extra space after openning parenthesis!') print('I have an extra space before closing parenthesis!' ) print( 'I have two extra spaces inside parentheses!' ) print ('I have space after function name')
Here is a good example:
print('I follow the PEP-8 rule!')
Now, please review the examples provided below and match them with the corresponding descriptions.
Match the items from left and right columns Report a typo print( 'Madam, I am Adam' ) print( 'Madam, I am Adam') print('Madam, I am Adam') print ('Madam, I am Adam') extra spaces after function name no extra spaces extra spaces within parentheses extra spaces after an opening parenthesis
- Assistant
Let's match each example with the corresponding description:
-
print( 'Madam, I am Adam' )- This has extra spaces after an opening parenthesis and before a closing parenthesis. So, it actually combines two descriptions, but if we go by the first rule it breaks, it has "extra spaces after an opening parenthesis." -
print( 'Madam, I am Adam')- This has extra spaces after an opening parenthesis. -
print('Madam, I am Adam')- This follows the PEP 8 rule with no extra spaces. -
print ('Madam, I am Adam')- This has extra spaces after the function name.
So the match would be:
print( 'Madam, I am Adam' )- extra spaces after an opening parenthesisprint( 'Madam, I am Adam')- extra spaces after an opening parenthesisprint('Madam, I am Adam')- no extra spacesprint ('Madam, I am Adam')- extra spaces after function name
-