Sie sind auf Seite 1von 1

7/4/2017 REST APIs with Flask and Python

Go to Dashboard

Flow controlloops and ifs


This coding exercise has two steps.

1. Modify the method even_numbers() so that it only returns a list of even numbers (2, 4, 6, etc...)
2. Modify the method user_menu(choice) so that if choice is "q" , it returns "Quit" . Make sure
that if choice is "a" it still returns "Add" .

exercise.py 1 numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]


2
3 # Modify the method below to make sure only even numbers are returned.
4 def even_numbers():
5 evens = []
6 for number in numbers:
7 evens.append(number)
8 return evens
9
10
11 # Modify the below method so that "Quit" is returned if the choice parameter is "q".
12 # Don't remove the existing code
13 def user_menu(choice):
14 if choice == "a":
15 return "Add"
16

Line 1, Column 1 All changes saved Reset Code

About Us (https://about.udemy.com/) Mobile Apps (https://info.udemy.com/ufb-mobile) Privacy Policy (/terms/ufb-privacy/) Terms (/terms/ufb/) Support (/organization/support/)
Check Solution Continue

https://naspers.udemy.com/rest-api-flask-and-python/learn/v4/t/quiz/297514 1/1

Das könnte Ihnen auch gefallen