Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (Retired) Pick a Number! Any Number! Imports

Sue Dough
Sue Dough
35,800 Points

Nothing I do passes :( I keep reading indent on the forums and can't figure it out.

Hi I can't figure it out. I did some searching in the forums and none of the answers seem to work for me.

random_num.py
import random
    def random_num(a_list):
    a_list=[1,2,3,4,5]
    random_num = randint(0,(len(a_list)-1))
    return a_list[random_num]

2 Answers

Here is the right code.

import random
def random_num(thisIsInt):
  randomNum = random.randint(1, thisIsInt)
  return randomNum

Thank you!

Keep up the good work.

Hi!

Try un-indenting your whole function so it is on the same level as your import. After that, try indenting all of the code after the function call and that should work great for you!

Sue Dough
Sue Dough
35,800 Points

Like this? Can you please paste the proper code?

import random
def random_num(a_list):
  a_list=[1,2,3,4,5]
  random_num = randint(0,(len(a_list)-1))
  return a_list[random_num]