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 (2015) Letter Game App Random Item

Andriy Bobrovych
Andriy Bobrovych
4,781 Points

i don't understand that task

Hi. a don't understand what i must do in this task

item.py
# EXAMPLE
# random_item("Treehouse")
# The randomly selected number is 4.
# The return value would be "h"
import random
def random_item(iter):
    retur = random.randint(0, len(iter) - 1)
    r

3 Answers

Alx Ki
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alx Ki
Python Web Development Techdegree Graduate 14,822 Points

Hi, Andriy Bobrovych!

Your code is right just not finished.

    import random

    def random_item(iter):
        indx = random.randint(0, len(iter) - 1)
        return ................

All you need is to return your iter's [indx] item.

Henry Garmendia
Henry Garmendia
Courses Plus Student 11,762 Points

@alexey did it really worked being a Techdegree Student, is it worth it?

Andriy Bobrovych
Andriy Bobrovych
4,781 Points

i now, i have not read an example, already done. Thank you!!

Alx Ki
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alx Ki
Python Web Development Techdegree Graduate 14,822 Points

Henry Garmendia , trying to answer your question:

  1. Don't know yet)). I need a couple more months to finish techdegree. But I also have 9 projects done and it feels so good!
  2. If you mean money, asking about worth, then yes. I pay 99$/month for structured and nicely organized courses. Even here in Russia such courses are more expensive and much worse at the same time.
  3. Talking about the most important thing - getting job, can say nothing for now.. But I'll do my best)

And what do you think?

Henry Garmendia
Henry Garmendia
Courses Plus Student 11,762 Points

Sounds good, I was thinking about paying for Techdegree myself but I wasn't sure if it was worth the try... So, it is alot different then the courses as a Pro student? I would like to follow your progress on GitHub if you don't mind, and check your projects out.

Henry Garmendia
Henry Garmendia
Courses Plus Student 11,762 Points

I sure will, I would like to see the projects you been working on...