My code works, but should it? PygLatin 8 Word Up


#1

https://www.codecademy.com/courses/python-beginner-2W5v7/1/2?curriculum_id=4f89dab3d788890003000096#


My code works perfectly. But I am not sure that it is supposed to. It works perfectly in the sense that when I use the Save & Submit button, I get "Way to go! Start Next Lesson"

1] As far as I understand, the variable word, now holds not only original, but the new and improved original which is in lower case?.

In terminal
Enter a word: Boat
Boat
None

2] I am guessing the reason I am still getting "Boat and not "boat" is because I still have a "print original" and not "print word" ?

3] I was hoping to get an error, so I could test the debug. But as far as I see, the only way to check is by clicking on the Submit & Save button, or is there another way? Because as soon as I do that and receive a "Way to go! Start Next Lesson, the "Reset" or "Undo Code" buttons disappear and I don't see a natural way to go back, to test again. Am I missing out on something?

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    word = original.lower()
    first = word[0]
        print original
else:
        print 'empty'

#2

Well, you are going to get an indentation error... but I'm not going to tell so you can figure out how to fix it. :slight_smile:

Why is that? Well it's because your printing the "original" word you typed in... If you printed word, it would print the lowercase version of your input because word holds original.lower(). :slight_smile:


#3

Thanks for a quick reply.
1] My original indentations works. Not getting an error there. But from what I write in the question window, and how the code came out in the preview are two different things. I let it be, since it seemed that's what it wanted. For example the "&gt", which I see in my code here, came in the preview window, but not where I wrote it.

2] Yes, I know. Kind of answered it myself. My point is that I am doing it, so I get a chance to debug it, or try out the debugger, ...

3] ... But how can I make a mistake and try to debug it, without using the Save & Submit button and then get a Way to go!? In the terminal for example, I would also like to try out not writing anything, so I would get the "empty" option after hitting the Return key. But every time I try something, it always seems to work and pushes me to the next page.

Put another way, I want to play around and check out different options, to see what works and what doesn't, without using the Save and Submit and getting Way to go! Next (even when it seems that the code is obviously wrong).


#4

Yeah, it's weird because even if I make in a mistake in a certain lesson, It'll still let you pass (I think it's by default after you pass, but I'm not sure...)

But, yeah, if you want to test out your code and try to create some errors and etc, then you can use an online code editor/text editor (if the terminal doesn't suit you) if you'd like. Check out the link below :slight_smile: :point_down:

Hope this helps :slight_smile:


#5

Thanks :slight_smile: That link was great.
I do have Python on a few computers. But not the one I am using for Codecadamy. But that website was easy access and let's you play around with the code, So I will definitely use it. Thanks for your help.


#6

Sure, no problem. :thumbsup: Happy coding! :smiley:


#7

I was having the same problem until I saw the little 'x' all the way to the right in the same bar with 'Save & Submit'. If you click that, you can try different ways and test your code.

Hope that helps!


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.