1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

any python programmers to help me with my code ?

Discussion in 'BlackHat Lounge' started by jammy, Jun 18, 2009.

  1. jammy

    jammy Junior Member

    Joined:
    Dec 5, 2008
    Messages:
    127
    Likes Received:
    110
    at the moment , i am learning python from micheal dawson's e-book , and i need some help on the word jumble game

    i dont see an error , but during execution , i am not able to make the program , display anything :(

    can any one check it out for me ?

    Code:
    import random
    
    WORDS = [ "apple" , "ball" ,"cat"]
    
    word = random.choice(WORDS)
    
    jumble = ""
    
    correct = word
    
    while word:
          position = random.randrange(len(word))
          jumble += position
          word = word[:position] + word[(position + 1):]
          
    
    print """ welcome to the jumble game"""
    print " the jumbled word is" , jumble
    
    guess = raw_input("\ntake a guess :")
    guess = guess.lower()
    
    while (guess != correct) and (guess != ""):
          print " thats not the right word "
          guess = raw_input("take a guess :")
          guess = guess.lower()
    
    if guess == correct:
          print " thats right"
    
    raw_input(" press a key to exit ")
     
  2. jammy

    jammy Junior Member

    Joined:
    Dec 5, 2008
    Messages:
    127
    Likes Received:
    110
    Dosent seem like , i am going to get help here .

    Mods please delete this thread.
     
  3. homenet

    homenet Power Member

    Joined:
    Jan 5, 2009
    Messages:
    790
    Likes Received:
    338
    Location:
    Dimension X
    Dude, you waited like an hour for a response and said your not going to get any help.. ever heard of patience? :p
     
    • Thanks Thanks x 1
  4. MuonTrail

    MuonTrail Registered Member

    Joined:
    Mar 5, 2009
    Messages:
    96
    Likes Received:
    93
    If its not displaying anything at all... then it sounds like your first while loop isn't ending. I'd start your debugging efforts there. ;) As a place to start, make sure your variable "word" will eventually evaluate to false to kick out of the loop.
     
    • Thanks Thanks x 1