+ 1
what is the answer to this question
numbers = list(range(5, 10, 2))
2 Respuestas
+ 8
alvin gachogu
If you print the statement you will get the answer...
This will return list value,
[5,7,9]
According to the range first 5 printed and it is incremented by 2 so 7 again incremented by 2 so 9
It will Stop since range is upto 10 which is exclusive..
+ 6
[5, 7, 9].
The list() function creates a new list by converting an iterable (in this case, the range range(5, 10, 2)) to a list.
The range range(5, 10, 2) generates a sequence of numbers starting at 5 and increasing by 2, up to but not including 10. This means that the list numbers will contain the numbers 5, 7, and 9.
Here is an example of how it could be used:
https://code.sololearn.com/cM5a2L3NIOfJ/?ref=app