Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Even Odd Status List Comprehension

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Even Odd Status List Comprehension. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Write a Python function that takes an integer n and returns a list of pairs for all numbers from 1 to n inclusive. Each pair should contain the number and a string indicating whether it is "even" or "odd". Use a list comprehension to build the result.

Constraints

  • 0 <= n <= 10^4
  • Return a list of tuples in increasing numeric order
  • Use a list comprehension in the implementation

Function Signature

def even_odd_status(n):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output