Unknown Error


#1

Hi, I try not to ask too much on Codecademy discuss, but I was editing my code and I got an unknown error:
UnknownError:4499487034400744422399883699070518459977417540107580784616832359547547245109505090527272972979722082995740522542872829656127723057561581320513974503373876961888748328699295727630511623520954224253428145606236015862418679033632227728004302007503375718918249856914531710839496313586763217751256912590039287070262248026920501928387281969933665083457853128251416873901851787868215565511081942479791787475` (there's more, more, more numbers). is that a glitch? I hope what I'm asking isn't bad. :sweat:
I know my code is wrong, and I get too many infinite loops, but yeah I just wanted to know. I refreshed the page many times and the lesson freezes on me (probably because of some sort of overload). What should I do?
https://www.codecademy.com/courses/python-beginner-en-pwmb1/1/6?curriculum_id=4f89dab3d788890003000096#




#2

This is probably happening because the code is using append to add to start_list while it's iterating through start_list. If start_list is having a number added to it every time it goes through the for loop, the numbers in start_list will never end.

Hopefully this helps you fix the problem.


#3

I will check. thanks for fast reply.


#4

Like this?

start_list = [5, 3, 1, 2, 4]
square_list = []

# Your code here!
for start_list in square_list:
    start_list.append(square_list ** 2)
    print square_list
square_list.sort()

console:none
And square_list should be the same length as start_list.

or should square_list.sort() be before print square_list??? I don't think so because that would be an unexpected indent. :confused:
Codecademy doesn't have the greatest instructions on how to do this, and I dont have a firm understanding on .append() so that makes things worse.


#5

This line

for some_variable_name in start_list:

will go through every number in start_list one at a time and each time that number will be represented by some_variable_name. So, according to the instructions you need to square that number each time and append it to the square_list. Perhaps a good variable name for use in the for loop would be number and that might make things clearer:

for number in start_list:

append is a function that can be called on a list. It takes whatever argument is passed to it and adds that value to the list it was called on. So if I were to do

my_list = []
my_list.append(1)
my_list.append(2)

The contents of my_list would now be [1, 2].


Let me know if you give it another try and anything still doesn't make sense!


#6

I will check and see how it works, thanks!


#7

@liamseanbrady, I figured out to append things, but when I try to square it and throw it into square_list, it doesn't work.

start_list = [5, 3, 1, 2, 4] 
square_list = []
start_list.append(square_list)
# Your code here!
for square_list in start_list:
       print start_list
square_list.sort()

start_list now contains:

[5, 3, 1, 2, 4, []]
[5, 3, 1, 2, 4, []]
[5, 3, 1, 2, 4, []]
[5, 3, 1, 2, 4, []]
[5, 3, 1, 2, 4, []]
[5, 3, 1, 2, 4, []]
None

and square_list contains:

5
3
1
2
4
[]
None

I just switch what to print and that's what I got. How do I not modify start_list?

Do I do this:
square_list = start_list ** 2
or do I make a new variable? When I tried this, it didn't work and I read my notes and examples to double check, but nada-nope -- nothing. :frowning: I know I'm not supposed to make any statements so I didn't do that.


#8

start_list must of gotten looped and now it contains the [] from square_list. And square_list isn't really 'sorted'. square_list contains the list numbers from start_list, but it's not squared. :confused:
-I replied to myself accidentally.-


#9

Nevermind. I figured it out. I didn't know I was supposed to use list in my code. Thanks! :slight_smile:


#11

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