View Lists in IPython Notebook Returning [No, No, No ...]

I am looking to generate a list of enumerated strings using list comprehension in IPython Notebook. It works, but gives me a strange result that I don’t understand.

cols = []
[cols.append('Value'+str(hour)) for hour in xrange(1,25)]

After starting the cell, it colsreturns the correct list [Value1,Value2...Value24], but in my laptop I get a list of 24 results None. Sample photo

The code works, but the weird conclusion makes me feel like I did something wrong and it looks messy. Why am I getting this conclusion, and is there a way to get rid of it?

+4
source share
2

None, , cols.append('Value'+str(hour)). cols , , , , append() .

cols = ['Value'+str(hour) for hour in xrange(1,25)]

+2

cols.append(value) cols, None, cols , cols , , :

cols = ['Value'+str(hour) for hour in xrange(1,25)]
+2

Source: https://habr.com/ru/post/1685340/


All Articles