Am i not allowed to flashify my code?


#1

hi! there is nothing wrong with my code but am I not allowed to do what my title says?

from random import randint

# Generates a number from 1 through 10 inclusive
random_number = randint(1, 10)

guesses_left = 3
# Start your game!
print "Welcome to the guessing numbers game! If you guess the right number, you win! And if you don't, you lose! Let's start!"
while guesses_left != 0:
    guess = int(raw_input("What is you guess?"))
    if guess == random_number:
        print "You win! The number was ", random_number, "! Here's your Fab prize! The sweet taste of victory! Yup! That's it! You can go now! Enjoy the rest of your day!"
        break
    else:
        guesses_left -= 1
        if guesses_left == 0:
            print "Incorrect! Oh NO! You are out of guesses! SO you LOSE! TOO bad! BUT, there is always next time! until then, GOOOOOOOOOD BYE!"
        else:
            print "Incorrect! Ouch, there goes a guess! But, Don't give up yet! you still got ", guesses_left, " guesses left! Give it another shot!"

#2

that depends, some exercise are more flexible then others, some exercises allow for a lot of flexibility, so you can improve your code, in some exercises this is more difficult

You can always optimize the code outside the lesson, does that answer your question?


#3

ok, but what am I missing from this lesson?


#4

can you post the exercise url?


#5

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