Move it on back.. Just a question


This is the following code I have for this lession.. It said I was correct...

pyg = 'ay'

original = raw_input('Enter a word:')
new_word = word + first + pyg

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

My question is, does it matter where I place the NEW string? As you can see I placed it just under "original = raw_input('Enter a word:')"

But as I looked through the Q&A forum and read other "Move it on back topics" I noticed other users placing their new string other places in their code...


Actually this line is suppose to be in a different place, it should be under the if statement. Remember, we are only suppose to make the new string AFTER we have checked that the user input(original) fits the criteria. :slight_smile:

It that still confuses you then think of it this way, when people order a wedding cake, they want it in a specific shape. Now it would be much easier to make sure that the design of the cake fits the requirements of the people who are ordering it( if statement). Rather than making it and then having to throw it away because the people didn't like it.


that example does help me to understand If statements a liitle better.. but why does the console say it is correct the way I have it after I run the code?


If it passes, it passes. Some languages are nice like that.

But keep in mind that writing your code is like writing an instructions manual for people. It needs to be logical, clear and clean- making it easy-to-follow. Other people will also be looking at your code (if you plan to be a programmer/dev or you want to share it) so it's also a great practise to make it legible and understandable by all.


It lets you pass because it technically is stil correct it's just efficient to check the criteria first. Like the wedding cake example, if the cake doesn't fit the requirements they can make it again, it's just tedious to do it that way though. :slight_smile:


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