Q:

Generate a Python list of all the even numbers between 4 to 30

belongs to collection: Python Functions Exercises

3

Generate a Python list of all the even numbers between 4 to 30

Expected Output:

[4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Hint:

  • Use the built-in function range() to generate the sequence of numbers between the given start number to the stop number with a step = 2 to get even numbers.
  • pass range() function to a list constructor to create a list

solution:

print(list(range(4, 30, 2)))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Find the largest item from a given list using pyth... >>
<< Assign a different name to function and call it th...