isdsucph / isds2021

Introduction to Social Data Science 2021 - a summer school course https://isdsucph.github.io/isds2021/
MIT License
22 stars 37 forks source link

Problem 0.2.4 #4

Closed Casper17-max closed 3 years ago

Casper17-max commented 3 years ago

When I try to run this code, it says 'Kernel busy' with a black circle instead of a white one: image

When I interrupt the Kernel, it says this: image

It seems like the problem is somewhere in line 3 (the arrow) but I don't know why.

joachimkrasmussen commented 3 years ago

Hi Casper

It seems that i only increases by 1 when your if statement is true. This causes i to get stuck at numbers where the condition is not satisfied. This could for instance be 1. Consider rearranging your loop just a tiny bit.

Please let me know if this was not helpful.

Best, Joachim

Casper17-max commented 3 years ago

I have tried to move things around and Google, but i don't understand why it's still wrong, and how the notation of an if statement in a while loop should be.

joachimkrasmussen commented 3 years ago

You seem to have a problem with the indentation. It seems that you have indented i += 1 twice. What happens if you don't indent it? What happens if you indent it once?

Best, Joachim

Casper17-max commented 3 years ago

When I don't indent and indent once, I get the following errors after interrupting the kernel, respectively:

image

image

joachimkrasmussen commented 3 years ago

Instead of writing i =+ 1, try and write i += 1. With the former, you basically just say that i = 1 as 1 is implicitly a positive (+) number. I can recomment simply writing i = i +1 when in doubt.

Does it work now?

Best, Joachim

Casper17-max commented 3 years ago

It worked, thank you :-)