id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

gaurav1780@gmail.com 04_lists > naturals
prev  |  next  |  chance

Define a function that when passed an integer (say n), returns a list containing the numbers 1, 2, ..., n in that order. Return an empty list if n <= 0.


naturals(0) → []
naturals(-5) → []
naturals(8) → [1, 2, 3, 4, 5, 6, 7, 8]

...Save, Compile, Run (ctrl-enter)

def naturals(n):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 3 Post-solution available

Copyright Nick Parlante 2017 - privacy