#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    44
    Rep Power
    2

    What am i doing wrong?


    def guess (unguessed_consonants, unguessed_vowels,letter):
    '''(str,str,st)-> tuple of (str,str)

    returns a tuple of unguessed_consonants and unguessed_vowels with the letter removed from the string depending on whether the letter is in the sring
    unguessed_consonants or unguessed_vowels

    >>>guess('bcdfgh','aei','a') <-- This has a problem
    ('bcdfgh','ei')

    >>>guess('bchjklmn','iou','b')
    ('chjklmn','iou')

    '''
    for i in unguessed_consonants:
    if (i == letter):
    a = unguessed_consonants.replace(letter, "")
    b = unguessed_vowels.replace(letter, "")
    return (a,b)

    So above is my code, it removes the consonants from the string fine, but when you put a vowel it says that 'a' is referenced before assignment (what does that mean, and what do i need to do to fix it???) Thanks
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    That definitely isn't HTML.

    Comments on this post

    • MauroEldritch agrees
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    44
    Rep Power
    2

    SOrry


    Originally Posted by E-Oreo
    That definitely isn't HTML.
    Lol sorry, this is my first time using these forums and i am a little out of it..

    Comments on this post

    • MauroEldritch disagrees : Not meant to be bad on you, but sections here are really cleary marked.
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    What language is it? Someone can move the thread to the right board.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo