# Function to return a list of natural numbers

Page 1 of 1

## 2 Replies - 585 Views - Last Post: 25 March 2013 - 07:52 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=316642&amp;s=ad55c5d629951593d77d2021654ef550&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Brilliantwarrior

Reputation: 0
• 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(" 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

• Freelance developer

Reputation: 6214
• Posts: 13,716
• 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.

### #3 Brilliantwarrior

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

## Re: Function to return a list of natural numbers

Posted 25 March 2013 - 07:52 AM

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

This is a duplicate post.