The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Python


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 11-16-2008, 07:27 PM
Stultus Stultus is offline
Novice
Join Date: Nov 2008
Posts: 1
iTrader: (0)
Stultus is on a distinguished road
Icon12 I can't find my bug.

I'm new to Python, and of course the first program I make seems to be riddled with bugs. If anyone can tell me what I've done wrong, I would greatly appreciate it. Here is my code:

Code:
print 'Welcome to FlashCards.\n'

usrinput = ''   # Defining some variables - this one is for user input
number = 1      # This one has multiple uses
terms = []      # This is a list that will contain the frontside of the "flashcards"
ansrs = []      # This list will contain the backside of the "flashcards"

while usrinput != "Go to answers.": # This loop prompts the user to input the frontside of the "flashcards" until they input 'Go to answers.'
         usrinput = raw_input("Please enter term %s or type 'Go to answers.'\
to start typing in the answers.", number)
    number = number + 1 
    terms.append(usrinput) # Put the user's input into the terms list.
    s = ', '.join(terms) # Join the parts of the terms list into one string.
    print 'The terms are so far: %s', s # Print how many terms the user has inputed
                                        # using the string just created.
number = 1 # Reset the number variable when the loop ends.

while usrinput != "Test me!": # Keep prompting the user for the flipside of the "flashcards" until they say 'Test me!'.
    usrinput = raw_input("Please enter answer %s or type 'Test me!' to \
start testing yourself.", number)
    number = number + 1 # With every loop, this number increases.
    ansrs.append(usrinput) # Put the user's input into the ansrs list.

number = 0 # Reset the number variable

while number <= len(terms) # Prompt the user for the flipsides of the "flashcards."
    usrinput = raw_input(terms[number])
    if usrinput == ansrs[number] # The user input what they think is the answer. Rinse and repeat until they go through all the terms.
        print "Correct!"
        number = number + 1
    else
        print "Incorrect."

print "You finished!" # Obviously tells the user they finished.

# The program is buggy and incomplete, currently only allowing the user
# to go through the cars once. After they have, they have to reenter all
# the cards and their reverse sides again. It also never checks to see
# the user entered the same amount of terms as answers.
It's supposed to be a simple (based on what I've learned so far) flashcards game.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by Stultus : 11-17-2008 at 04:49 PM. Reason: fixed a teensy bit of my coding, added comments
Reply With Quote
  #2 (permalink)  
Old 11-16-2008, 10:02 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
PT Admin
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,122
iTrader: (0)
HelloWorld is a jewel in the roughHelloWorld is a jewel in the roughHelloWorld is a jewel in the rough
Well, what is your program supposed to do?

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #3 (permalink)  
Old 11-17-2008, 09:08 AM
MrPickle's Avatar
MrPickle MrPickle is offline
PT Admin
Join Date: Nov 2007
Location: England, Lincolnshire
Posts: 332
iTrader: (0)
MrPickle is a jewel in the roughMrPickle is a jewel in the roughMrPickle is a jewel in the rough
You can use code tags to do the spacing;
[ code ] YOUR CODE HERE [/ code ] (removed the spaces between the brackets)

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply

« python car alarm | - »

Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 08:15 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50