sciencenic
Posts: 5
Joined: Fri Jan 08, 2016 3:15 am
Occupation: Student

Broken code in python project?

Postby sciencenic » Wed Oct 18, 2017 6:36 pm

I wanted to try the pass word guesssing project and the code won't load. It has alot of errors with indenting. Whoever wrote it might not know that in python, the indentiing is important not like in C and Java. I tried to fix it but there are so many errors. A friend of mine did it last year without a priblem. Is the old code available?

bfinio
Expert
Posts: 293
Joined: Mon Aug 12, 2013 2:41 pm
Occupation: Science Buddies Staff

Re: Broken code in python project?

Postby bfinio » Fri Oct 20, 2017 5:15 am

Hi sciencenic -

I wrote the new code in IDLE on my computer (Windows 10) and it opens and runs fine. I also had a colleague run it in IDLE on a Mac and it worked there. Any more information you could provide about problems with the new code would be appreciated - this might help us track down the problem and figure out if other people will encounter it:

- What program are you using to open the code? (IDLE or another text editor?)
- What version of Python/IDLE? This was written and tested in Python 3.6.1, I am not sure if it will work in Python 2.
- In IDLE, if you go to Options -> Configure IDLE, on the first tab ("Fonts/Tabs"), what is the "Indentation Width" set to? Mine is set to the Python standard (4 spaces).
- What operating system are you using?
- Do you get any on-screen error messages when you try to open it? If so, can you paste their text into a comment here?
- If the code does open, is the indentation messed up? Can you upload a screenshot of the code (or email it to scibuddy@sciencebuddies.org if you can't upload an image attachment to the forum).

In the meantime - I tried to upload the old code here but the forum won't take .py file extensions. If you email us at scibuddy@sciencebuddies.org, we should be able to reply and send you the code. (Do not post your contact information in the forums).

Thanks, and hope we can get this sorted out.

Ben

sciencenic
Posts: 5
Joined: Fri Jan 08, 2016 3:15 am
Occupation: Student

Re: Broken code in python project?

Postby sciencenic » Fri Oct 20, 2017 6:07 am

The Mac at school uses idle 3.5 and the code opens it just doesn't run. Teacher looked at it this morning and said the problem was in a bunch of prints that don't do anything, so she removed all of those and we got it running. She said there were spaces and tabs mixed together if that help you. She also thinks she has the old code around if we need it. So I think we have it fixed. There were also some places where it stops in the middle beucase of input statements. She figured that was old debugging code and took those out too. It's running now. Thanks!

bfinio
Expert
Posts: 293
Joined: Mon Aug 12, 2013 2:41 pm
Occupation: Science Buddies Staff

Re: Broken code in python project?

Postby bfinio » Fri Oct 20, 2017 7:08 am

Hi sciencenic -

I know about the tabs vs spaces problem and just double checked my code. I think it is all spaces because my installation of IDLE automatically converted tabs to 4 spaces when I used them - but there's a chance that's different between either our OS'es or our versions of IDLE (3.5 vs 3.6), so your machine might be seeing a mix of tabs and spaces.

As for the print statements and inputs - I put those in there to slow the code down a bit, so less experienced students would be forced to pause and read the output to understand what's happening. Previously we had problems where students without any real Python experience would just download and run the code, but have no idea what was going on. It sounds like you know what you're doing, so obviously you're OK just removing those if they get in the way or cause problems. The print statements don't cause any issues for me, but again I'm not sure if there was a slight change in the way you print a blank line between 3.5 and 3.6 I'm using print(), but maybe it should be print(" "), etc.

Glad you got it working, please let us know if you run into any other issues. We just posted the new code recently, so bug reports are always welcome!

bfinio
Expert
Posts: 293
Joined: Mon Aug 12, 2013 2:41 pm
Occupation: Science Buddies Staff

Re: Broken code in python project?

Postby bfinio » Wed Oct 25, 2017 9:58 am

Hi sciencic,

Somebody else reported similar problems with print statements in this thread:

viewtopic.php?f=27&t=17138&p=61713#p61713

We are looking for help debugging because we have had four different people test this code at Science Buddies, in different versions of IDLE (3.3, 3.5, and 3.6 on Windows and 3.6 on Mac) and it worked for everyone. So, we cannot identify the source of the error. If possible, could you let us know:

- exactly what error messages you get when you try to run the original code
- what changes you made to the code to get it to run?

Thanks!

Ben

anasira
Posts: 3
Joined: Tue Oct 31, 2017 5:04 am
Occupation: Parent

Re: Broken code in python project?

Postby anasira » Tue Oct 31, 2017 5:09 am

If you figure it out, my son would appreicate it.

Thank you kindly!


Return to “Grades 9-12: Math and Computer Science”