[Tutor] Wrapping my head around global variables!!

Nevins Duret duretn at bellsouth.net
Fri Jan 28 16:22:16 CET 2011


Hello Python collective,

         I am trying to wrap my head around what exactly is causing me 
not to get any output or error message in the following code:

> #!/usr/bin/env python3.1
>
> import random
>
> def main():
>
>     def chosen_letter():
>
>         chosen_letter = Consonant()
>         chosen_letter = Vowel()
>
>     return chosen_letter
>
>     Consonant = random.choice( [B, C, D, F, G, H, J, K, L, M, N, P, Q, 
> R, S, T, V, W, X, Z] )
>     Vowel = random.choice( [A, E, I, O, U, Y] )
>     print("Choose a letter"( Consonant, Vowel ))
>     print("You randomly chose"( Consonant, Vowel ))
>
>     if Consonant == ( "B C D F G H J K L M N P Q R S T V W X Z" ):
>         print("You randomly chose a Consonant")
>     else:
>         print("You randomly chose a Vowel")
>
>     if Consonant:
>             gameStatus = "CONTINUE"
>     elif Vowel == A or Vowel == E or Vowel == I or Vowel == O or Vowel 
> == U or Vowel == Y:
>             gameStatus = "FINISHED ALL VOWELS"
>
>     if gameStatus == "FINISHED ALL VOWELS":
>         print("FINISHED DISPLAYING ALL VOWELS")
>     else:
>         print("LOOKING FOR MORE VOWELS")
>
> if __name__ == "__main__": main()
>
All this code is intended to do is to have a user, in this case my 4 
year old, choose letters of the alphabet until all vowels are 
specified.  For whatever reason I'm neither getting an error message nor 
am I obtaining any messages in the output console.  Any help on this 
would be greatly appreciated.  I eventually want to make this into a gui 
in order to introduce young kids to programming, by having the letters 
print out to screen as the user makes choices based on vowels and 
consonants.  Again, thank you for any help and expertise.

Best Regards,

freesparks


More information about the Tutor mailing list