2 Replies - 423 Views - Last Post: 25 March 2013 - 07:52 AM Rate Topic: -----

#1 Brilliantwarrior  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 05-December 12

Function to return a list of natural numbers

Posted 25 March 2013 - 07:37 AM

I am currently learning Python 3, independently. I'm having difficulty with creating an algorithm to write the function, once I know what I need to do, then I can do it.
Task- Write a function naturalNumbers which takes a positive integer n as input, and returns a list [1, 2, ] consisting of the first n natural numbers.
def naturalNumbers(n):
   d = n+1
   for a in range(1,d):
      b = [d-a]
      print(B)/> 


I'm supposed to use: a For Statement, List Repetition and/or List Concatenation.
A few pointers in the right direction would be greatly appreciated, thanks.

I'm not sure why the b in "print(B)" is capitalizing, or adding a forward slash and bracket.

Is This A Good Question/Topic? 0
  • +

Replies To: Function to return a list of natural numbers

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5681
  • View blog
  • Posts: 12,223
  • Joined: 02-June 10

Re: Function to return a list of natural numbers

Posted 25 March 2013 - 07:40 AM

This is a duplicate post.
Please don't submit twice.
Was This Post Helpful? 0
  • +
  • -

#3 Brilliantwarrior  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 05-December 12

Re: Function to return a list of natural numbers

Posted 25 March 2013 - 07:52 AM

View PosttlhIn`toq, on 25 March 2013 - 10:40 AM, said:

This is a duplicate post.
Please don't submit twice.

I apologize, it was an accident.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1