Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

readme.md

AttributeError: 'NoneType' object has no attribute 'split'

I tried to call .split() on a variable that was None.

reproduce.py

username = None
parts = username.split("_")
print(parts)

Error message

AttributeError: 'NoneType' object has no attribute 'split'

fix.py

username = None

if username is None:
    print("Username not available")
    username = ""

parts = username.split("_")
print(parts)

Reflection

Forgot to check for None before calling a method.