Hello everyone,
https://www.codecademy.com/courses/learn-python/lessons/python-2-loops/exercises/while-youre-at-it
Why is my piece of code wrong here could someone kindly explain
Thank you
Jagmeet
Hello everyone,
https://www.codecademy.com/courses/learn-python/lessons/python-2-loops/exercises/while-youre-at-it
Why is my piece of code wrong here could someone kindly explain
Thank you
Jagmeet
the syntax error should be helpful? It tells you that your import is wrong. This would then allow to google how to use import.
I have removed the import but still the solution is different to what l have done and l don’t get why l am wrong
just a by the way question why is codecademy restricting the number of queries l can post and sets a time limit
what error do you get now then? Could you copy paste your code to the forum so I can actually run your code?
to filter out spam. Its unfortunate, but otherwise people would use the forum for spam and SEO.
num = 1
# Fill in the condition
while num <= 10:
# Print num squared
num ** 2
# Increment num (make sure to do this!)
num += 1
print (square(num))
So basically l have to wait for the time limit to end to be able to post a new query
here:
print (square(num))
you don’t have a square function and you don’t need a function. So why do you attempt to call this non-existing function?
squared means to the power of 2 (^2). which you should print each iteration of the loop
I personally don’t agree with the exercise to use a while loop here, a for loop would be a better fit
Also try the while loop. I think its good to learn, even though the for loop is the better fit here
Could l post my second query here if you don’tmind
Thank you
Depends, if related to this exercise, yes. If not, preferable make a new topic
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.