[Tutor] Wrapping my head around global variables!!

Elwin Estle chrysalis_reborn at yahoo.com
Fri Jan 28 20:15:29 CET 2011


I don't consider myself qualified to answer your question...but just in looking at your program and the description of what it is supposed to do, I'm a bit confused.  So let me get this straight...the user is supposed to choose a letter, and the program is supposed to tell them if it is a vowel or a consonant?  ...and keep looping through until they have chosen all the vowels?

...am I understanding this correctly?  If so, why use the random function at all?  Or is the program supposed to randomly choose a letter and the user specifies whether it is a consonant or a vowel?

In either case I don't see anywhere in the code where you actually have the user type anything.  But then, like I say, I am no python expert, by any means.

--- On Fri, 1/28/11, Nevins Duret <duretn at bellsouth.net> wrote:

> From: Nevins Duret <duretn at bellsouth.net>
> Subject: [Tutor] Wrapping my head around global variables!!
> To: tutor at python.org
> Date: Friday, January 28, 2011, 10:22 AM
> 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
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
> 


      


More information about the Tutor mailing list