I have been using a Python 3 environment to test and store code as I go. I have been able to work through the differences in Python 2 vs Python 3 pretty well until this chapter. I have found the ‘*’ helpful to allow me to use some of the code, but I don’t know why. Can anyone explain this for me, please.
Example working in Codecademy :
my_list = range(16) print filter(lambda x: x % 3 == 0, my_list) ...and from earlier in Advanced Topics... new_list = range(101) print(new_list[::5])
These work in Python 3+ as:
my_list = range(16) print(*filter(lambda x: x % 3 == 0, my_list)) new_list = [*range(101)] print(new_list[::5])