14. Pasing a range into a function


#1

So yea... I don't understand, therefore I can't complete this exercise :rage:
https://www.codecademy.com/courses/python-beginner-nzzVa/3/3?curriculum_id=4f89dab3d788890003000096
And HUZZA... I'm frustrated. :frowning:
But seriously help me PLEASE :slight_smile:

The error message are these:

Traceback (most recent call last):
  File "python", line 6, in <module>
TypeError: range() integer end argument expected, got list.

Help me please...

Here is the SECOND error message :rage:

                             |
                             |
                             |
                             V

Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: range() integer end argument expected, got list.

And here is my CODE (and it sucks):

def my_function(x):
    for i in range(0, len(x)):
        x[i] = x[i] * 2
    return x

print my_function(range([0, 1, 2]))

__
|_|
|_|
|_|
|_|
|_|

Yea... I SUCK at this

And I've made a LOT of conversations on helping me get my code right... i hope that's okay :grin:


#2

Sorry i couldn't spell the title properly because it contained the word As.s


#3

Though really... A.ss means donkey... :ideograph_advantage:


#4

Have another look at the instructions, they describe how the range function is used


#5

Hmm... how do I say this...
.
.
.
.
.
May I please have some help :grin:


#7

Hmm... I'm confused...

def my_function(x):
    for i in range(0, len(x)):
        x[i] = x[i] * 2
    return x

print my_function(range(0, 1, 2))

#9

@ionatan

Oops, try again. It looks like you didn't pass a range consisting of 0, 1, 2 to my_function.

#10

I'm back :rage:
and I'm still stuck :frowning:


#11

Oh hahahhaha I'm dumb THANKS :slight_smile:

def my_function(x):
    for i in range(0, len(x)):
        x[i] = x[i] * 2
    return x

print my_function(range(3))

This worked :slight_smile:


#12

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.