Testing Testing is this thing on


#1


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

Infinite Loops

Pig Latin translator that repeats from beginning after translation
It isn't working and I don't know why.
If anyone can help, that'd be awesome.

new_word1 = 'Random_Just_For_Variable'
new_word1 > 10
while True:
    for new_word1 in xrange(10):
        if new_word1 < 10:
            break
        else:
            pyg = 'ay'
            original = raw_input('Enter a Word')
            word = original.lower()
            if len(original) > 0 and original.isalpha():
                if word[0] == "a" and "e" and "i" and "o" and "u" and "y" :
                    new_word = word + pyg
                    new_word1 < 5
                    print new_word
                else:
                    new_word = word[1:] + word[0] + pyg
                    new_word1 < 5
                    print new_word
                    break
            else:
                print 'empty'


#2

"i" is not a condition, you'll want to compare it to something.

You'll also want to avoid magical numbers like 5 and 10, those are probably things that should be figured out by looking at the length of some string or similar.

You have two loops, seems unnecessary, remove all unnecessary code, everything should have a purpose.

If there are more problems, please explain in what manner it misbehaves so that we know what to look for


#3

I honestly just started learning how to do this today so I don't really know what all is unnecessary. I honestly just put those numbers in so that once I got to the point where I had the result I wanted from the translator it would go back, which I don't really even know why it would do it, it's just what I saw from some googling on how to make a loop work. Also, why is it that "i" isn't a condition? I don't really get why 5 and 10 would be different than having it be new_word1 < "1" or "2" either.


#4

Time to change approach. :stuck_out_tongue:
Remove anything that you can't explain exactly what it does and why it is required. If you needed some of that, then learn more about them.

We need to be deliberate, we need to understand what we write.

You can do something if "i" is equal to something, or if it's different from something etc, but you can't do something if "i"


#5

You're right, I was getting a little bit ahead of myself. I normally always prefer to know exactly what I'm doing and why I'm doing it when it comes to many of my hobbies but I was just hoping to have something relatively cool right off the bat. :stuck_out_tongue:

Thanks for the help though, I'll continue going through the tutorials on here until I get to the point where they explain what I wanted to know and then I'll come back to this project, although by that point I'm going to assume I'll be able to do a lot more.


#6

Essentially you're saying it should be removed, because it's not doing anything. And you'd be right.

You've got some idea of what you want the program to do right. So you need to come up with a set of actions that add up to that. Every single character of your code will as such have some purpose, you've put it there because it needs to be there.

We can write inefficient and/or long code and still require every part of it for it to work. Right now you've got stuff that just does nothing.

And if you don't know how to do something, look it up! It doesn't happen very often that I write anything at all without googling. We don't need to know it all, we don't need to memorize it all, we just need to get pretty good at finding the things we need.