I'm trying to understand the difference between these lines of code:
list(''.join(map(lambda x: str(x * 3), range(1, 4))))
Out: ['3', '6', '9']
as expected.
However:
list(''.join(map(lambda x: str(x * 5), range(1, 4))))
outputs ['5', '1', '0', '1', '5']
, while I expected: ['5','10','15']
In the same way that
[x for x in map(lambda x: str(x * 5), range(1, 4))]
ouputs ['5','10','15']
.
What's wrong here?
Aucun commentaire:
Enregistrer un commentaire