+ 1
I get a different result on my computer than the "correct" answer in module 6 of Pythonicness and Packaging. Why?
The question is, "What is the largest number this code prints?: " for i in range(10): if i > 5: print(i) break else: print(7) This is what I get on my computer when I run this code: 7 7 7 7 7 7 6 Seven is not the correct answer. I don't understand why that should be.
5 Antworten
+ 2
actually, the code in the module has different indentation, the "else" is completely unindented, causing 7 to never be printed because the "else" connects to the loop not the if statement Curt Prasky
+ 2
Thank you hinanawi, you're right. I didn't notice that before...a little hard to see on my screen. Yeah, that changes everything. I should have copied and pasted instead of typing myself. The highlighting during the copying makes the different indentation levels easier to see.
+ 1
The issue is that according to the module, the correct answer is 6, not 7. I answered 7 and got WRONG! When I answered 6, I got CORRECT! The problem is the code does print 7 as the largest number. There is something wrong here.
0
well, the largest number it prints is 7 so i see no issue with the answer. the code doesn't print any number bigger than 7.