Python Error unsupported operand type(s) for %: 'NoneType' and 'str' on my code -


so i'm having lot of trouble code... gives me error , don't see nothing wrong it! have 15 days studying python don't see error in code

when try run in python shell gives me error:

"unsupported operand type(s) %: 'nonetype' , 'str'"

please me out t____t i'm frustrated!

    @classmethod     def populationcount(cls):         print ("the total number of humans is: %d.") %(cls.population) 

the reason you're having problem in line:

print ("the total number of humans is: %d.") %(cls.population) 

is print executed first, stuff in first set of parentheses argument. return value of print used % operator. print returns none, python trying do:

none % (cls.population) 

and can figure out why that won't work.

to solve it, put entire % operation inside parentheses done before print called. after all, want result of interpolation printed.

print("the total number of humans is: %d." % cls.population) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -