Why this map return something?
the map function performs a given function on every object of an iterable. if you need a visual return try f = tuple(map(lambda x: x*2,lie)) if you dont convert the map return into a collection, like a tuple, map returns a generator object, which means, you can only iterate once over it.
Kevin what is generator object? cam you explain
a generator object gives you the ability to iterate only once over it, like in a for-loop, and then the generator object vanishes. for example, try: a = map(lambda x: x*2, (1, 2, 3)) for i in a: print(i) for i in a: print(i) output: 1 4 6 as you can see, it iterated only once over the generator object. this method of list comprehension is a good practice if your code allows it. if you converted the map() return into a list, tuple or set, the output would be: 1 4 6 1 4 6 as you can see, converting the generator object into a collection gives you the ability to iterate as much as you want over it. google 'python generators' to learn more about generator functions with their yield return and generator objects.
Map function returns new iterables, so if you need to print its values then u should convert it to list.
Mohamed Adel thanks
thanks Kevin for explaining briefly👍
Python — File Handling
Loop question, I've tried everything that I knew I just don't know. Please help me solve it out
Help me solve this (using loop)
What is wrong? Error on test.
Help me wiht python