"Brendy Siguenza" <[email protected]> wrote
This is the template that we are suppose to use while doing the
program, I
am a beginner to this programming language and really have no clue
what I am
doing
We don;t do homework problems for you but we can try to point
you in the right direction.
First off, it looks like you don;t understand dictionaries?
Try reading about dictionaries in a tutorial somwhere
(eg mine - the Raw Materials topic has some info)
NOW THIS IS WHAT I HAVE SO FAR, AND THESE ARE ALL
JUMBLE AROUND BECAUSE I HAVE NO CLUE WHERE
THEY ARE SUPPOSE TO GO PLZ HELP
Randomly coding is never a good idea. Try to work out how
you would solve it in your head before charging into writing code.
import random
#table of winning plays
win_play_for = {'r':'p', 'p':'s', 's':'r'}
This is a dictionary but you call it like a function.
See my comments above
#scoring results
player_score = 0
mach_score = 0
You don't use these? What are they for and when should you set them?
#kepp track of users' last plays
#assume initially an even distribution
hist = ['r', 'p', 's', 'r', 'p', 's', 'r', 'p', 's']
next = 0 #index of where to put next user play
You set these here so dpnt need to set them again inside the while
loop
while True:
hist = ['r', 'p', 's', 'r', 'p', 's', 'r', 'p', 's']
next = 0
don't need those two lines
guess = random_choice(hist)
len (hist)
The len() does nothing because you throw itr away.
Plus its always the same so no point in calculating it every
time round the loop.
#gets user's play
user_play = raw_input("What's your play (r|p|s)?")
hist[next] = user_play
next = next + 1
if next == len(hist):
next = 0
This bit is fine.
But where is the computers play?
user_play == win_play_for(mach_play)
mach_play == win_play_for(user_play)
These are dictionaries not function. See comment above
Also, where is the output? You never print anything?
Go think some more and come back to use with specific
questions about what you don't understand. Until you undersand
the basic structure of what you are trying to do there is not much
point in trying to fix the individual code issues. Try to describe
how it should work in English before describing it in Python. You
probably think better in English than you do in Python...
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor