I notice my knowledge in this is vastly dwindling due to how the instructions is describing what it wants me to do. Furthermore, I am using more hints and conclusions than I care to admit which means I am not learning much. The critical thing next is likely going to cause me to have a stroke. Is there any information out there that can be of better help to understand so I can come back and continue this?
I am having this same challenge.
Hi Guys
Just completed this exercise and had question regarding my code
single_digits = range(0,10)
for digits in single_digits:
squares =
for digits in single_digits:
squares.append(digits**2)
print(digits)
print(squares)
cubes = [digits ** 3 for digits in single_digits]
print(cubes)
Seems like I had to start another for loop in order to get the correct list squared (otherwise I just return 81 - if second for statemtent is ##)
New to all of this and cant quite see why this is the case.
Help greatly appreciated
Have the same question as yours… also curious why it’s returning the squared value of the last number.
It seems we are all in the same both, sometimes I feel so upset that I wanna break my laptop whenever is read the instructions, so confusing
Can anyone please help us @mtf where are you? You are my knight in shining armour here on Codecademy, you wanna save us, please?
Let’s have a look at your code to see where the problem is arising.
For step one we can either manually build the list,
single_digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
or assign a range,
single_digits = range(10)
The second step asks us to print each item in the list using a loop:
for x in single_digits:
print(x)
The third step asks for an empty list…
squares = []
Write that line above the loop, then move on to step 4.
for x in single_digits:
print(x)
squares.append(x ** 2)
Next we will print the squares list.
print(squares)
Step 6 assumes we know how to create a comprehension…
cubes = [x ** 3 for x in single_digits]
and finally, print that list…
print(cubes)
Hi Roy,
Thanks for your explanation. This is exactly how I wrote the code, but it didn’t woek. When I checked the solution, I found out that the empty square list was printed first whish is not the way the instruction was constructed.
I have to write it the way it was written in the solution before it worked. Mos of the few obstacles I have had with Codecademy tasks and quizzes are the way the instructions /questions are been made.
Thanks Roy for your usual help here
I had a bit of fun with this one:
single_digits = list(range(0,10))
print(single_digits)
squares=[]
cubes=[]
for i in single_digits:
squares.append(i**2)
print("the square of " + str(i) + " is " + str(squares[-1]))
cubes.append(i**3)
print("the cube of " + str(i) + " is " + str(cubes[-1]))
sample output
the square of 6 is 36
the cube of 6 is 216
the square of 7 is 49
the cube of 7 is 343
Enjoy!
Couple of things…
-
If we only wish to iterate and not access elements in a range it does not need to be cast as a list.
-
0
is the default start value so we don’t need to write it. Mind we don’t need to see what0**2
and0**3
are, so we can start with 1, or even 2.for i in range(2,10):
-
String formatting makes our code more readable and less wieldly.
print ("The square of {x} is {y}".format(x=i, y=squares[-1]))
Thanks for the tip/follow through!
…Starting from Loops, whole course is very poorly written.
Python 3 course at CA have issues in previous lessons too, but starting from chapter 5 it turns to playing games and trics with student’s mind.
Additionally, they don’t use PyCharm as workframe for their outside lessons what is frustrating.
Loops are one of the simplest topics (because it’s standard for / while / break / continue conditions), but not here.
As example, in 5.1.11 if fact they ask student to do range(10), but by request description it want to make xxx = [1, 2, …10].
And etc.
Same goes with me. Initially, the learning curve was going good at codecademy.
This is insane. I was doing SO well with codecademy and going to pay for the year after my trial was up. Been spending 2-4 hours a night digesting this stuff, starting from never coding or knowing anything about code. Once I hit lists, things became a little confusing… but I studied… and figured some things out on my own. But now? CC is throwing in a bunch of things and just expecting me to know how to use them? I was NEVER going to come up with “+=” ! WTF is that? How do I use the .pop() function? What variable does it attach to? What does it actually do? There’s no context whatsoever. They’ve been so good about explaining every little thing and suddenly it’s like I entered a completely new program. I was going to plunk down close to $300 tonight and now I’m considering just going somewhere else completely. I’m re-reading text over and over thinking it’s me and my comprehension levels, but I’m discovering that it is most certainly not. This is a real failure on the part of the CC team.
It appears as if the first 15% of the course was designed meticulously to get your financial commitment after the trial, and the rest was sloppily put together. I’m not sure that I’m going to continue – and I WANT to continue desperately because I’ve enjoyed the platform and it’s working really well for me – but forcing concepts and topics without properly introducing them is unforgivable. Is it just me?
Spend the money. You have a full year to capitalize on it. This becomes your court and there is time enough to sort out warts and all and still walk away with a complete experience. Careers have been launched from this site by many an apt pupil who didn’t walk away, despite the shortcomings. They more than made up for that by staying their course. Are you a quitter?
Oh, I feel you so much. I was so proud of my progress, really unterstood it, solved the challenges before on my own. But when Loops were introduced I didn’t get anything. The += operator wasn’t explained anywhere before, neither was .pop(). Maybe they want you to look it up and understand it yourself, and it did kinda work. But I felt bad for using the hints and was just typing it off. Read it a few times, tried to understand what’s happening. Did you do the project afterwards? Steps 1 - 12 I was like: Ok, maybe I got it? But Step 13:
Carly thinks she can bring in more customers by advertising all of the haircuts she has that are under
30
dollars.
Use a list comprehension to create a list calledcuts_under_30
that has the entryhairstyles[i]
for eachi
for whichnew_prices[i]
is less than30
.
You can userange()
in your list comprehension to makei
go from0
tolen(new_prices) - 1
.
No matter how hard I thought about it, I didn’t get it. Used the hint, typed it off, got it working but still not understanding why it did. Yeah, I don’t want to quit, but I guess what the people complaining here are trying to say is: The loops lessons aren’t very good compared to the lessons before! There’s such a big difference in speed of explaining what’s actually going on that people that were really motivated and willing to spend money suddenly think twice about it. Maybe rework that lesson somehow and introduce some elements earlier that are used here.
Any advice then how to get this loops section into my head? Don’t wanna continue with something new until I really understood it, maybe there are some more exercises I could try? Just finished the first project of this lesson needing to use two hints because I was really stuck.
Please post a link to the exercise page so we can see where you’re at.
https://www.codecademy.com/courses/learn-python-3/projects/carlys-clippers
This was the exercise I did yesterday and how far I came so far. Came through it but don’t feel like I really understood it. Should I just continue because it will get clearer later or really stay at this topic until I fully unterstand?
Keep reviewing and repeat anything that is still giving you trouble. Don’t hurry ahead with the idea that it will all become clear. We need to cement our understanding so we’re not walking in a fog.
Thanks for your help! Ok, will try all the loop challenges and maybe even lessons again and then look for some more challenges until I feel confident enough to move on.