python - Making a list in user-defined functions -


i'm trying understand error of:

  float object has no attribute 

here simplified version of code:

    def apple():              = input("first: ")              b = input("second: ")               list1 = [0..a];              list2 = [0..b];               print list1, list2 

here how error given

    >> apple()     >> attributeerror: 'float' object has no attribute 'a' 

since poster asked error specifically:

i believe in line list1 = [0..a];

the python interpreter takes expression 0..a, , parses float 0. followed call a attribute of 0., dot means in context.

as has been mentioned already, create range, use range(0, int(a)) instead.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -