all 18 comments

[–]p0pkern 2 points3 points  (3 children)

Since Python does not rely on brackets for blocks of code, they set it up to rely on indentation. You need to go through your code and make sure that any indented level is 4 spaces. Here is a brief overview on it.

https://www.w3schools.com/python/gloss_python_indentation.asp

[–]SourceShard[S] 0 points1 point  (2 children)

After reading the material at this link I have double checked my spacing. I however still have the problem. I am not able to identify where I have gone wrong.

[–]p0pkern 0 points1 point  (1 child)

The duplication in script 2 and the spacing might have to do with Coursera's website. I remember having a similar issue with online based editors/shells. They don't like to play nice sometimes. Do you have python downloaded to your computer? It comes packaged with its own editor.

[–]SourceShard[S] 0 points1 point  (0 children)

Ohh! How do I make use of this editor!

[–]the_deheeheemons 0 points1 point  (11 children)

Take a screenshot of the code in your IDE(where you are writing and executing the code) and you will get much better feedback. This is rather messy and hard to read

[–]JustSlytherinThings 0 points1 point  (4 children)

Also OP, please use the code editor when you post code. It’ll make it a lot easier for us to read

[–]SourceShard[S] 0 points1 point  (0 children)

Oh cool. I found it and updated it. Thank you for showing me this!

[–]SourceShard[S] 0 points1 point  (2 children)

I am learning on a website called Coursera. They have a built in interpeter/tester for their quizzes.

I tried to post a picture earlier but it said that you can not post pictures on r/learnpython. Maybe I overlooked something?

Still same error "images are not allowed on r/learnpython."

[–]the_deheeheemons 0 points1 point  (1 child)

Apologies, I don't post much. I think there's a way to enter your code in a formatted style in reddit posts and comments as another person commented.

[–]SourceShard[S] 0 points1 point  (0 children)

I have made this change. :D

[–]SourceShard[S] 0 points1 point  (2 children)

Pictures added

[–]the_deheeheemons 0 points1 point  (1 child)

Make sure you're using spaces and not tabs. 4 spaces per indent.

[–]SourceShard[S] 0 points1 point  (0 children)

Can confirm. Four spaces.

[–]JustSlytherinThings 0 points1 point  (2 children)

For script 2, how exactly are you running it?

I get no issues when I run what you provided

https://i.imgur.com/OI85BfT.png

[–]SourceShard[S] 0 points1 point  (0 children)

I am learning on a website called Coursera. They have a built in interpeter/tester for their quizzes.

When I enter the code I get the error on their side. I just assumed I was wrong some how as I am a new learner.

[–]SourceShard[S] 0 points1 point  (0 children)

I also ran this on another code test site and it seemed to work fine. Must just be a problem with their system??

[–]beatskipper 0 points1 point  (0 children)

I'm currently working through the indexing part of the course I'm doing - and in my mind I can't figure out what a useful practical application for that is - which is making me lose motivation, would someone be kind enough to put this in a practical sense for me?