PEP 8 conventions

Report a typo

Write the function check_name() that checks if an input variable name is in accordance with PEP 8 conventions:

  • Check if the variable name equals 'l' (lowercase letter el), 'O' (uppercase letter oh), or 'I' (uppercase letter eye). If it does, print "Never use the characters 'l', 'O', or 'I' as single-character variable names". If it does not, move to the next step.
  • Check if the name is all lowercase or uppercase. If all of its characters are lowercase, print the message "It is a common variable". If all of its characters are uppercase, print the message "It is a constant". In other cases, print the message "You shouldn't use mixedCase".

You do NOT need to call the function or take any input.

Sample Input 1:

directoryName

Sample Output 1:

You shouldn't use mixedCase

Sample Input 2:

I

Sample Output 2:

Never use the characters 'l', 'O', or 'I' as single-character variable names
Write a program in Python 3
def check_name(...):
...
___

Create a free account to access the full topic