Re: Replace blanks with letter

2013-08-22 Thread eschneider92
I wanted the program to stop only after all the letters were typed; why in the 
world would I try to write a program with blanks for each letter that seem 
intended to be filled, only to have it stop if the last letter is typed, or 
have to type each letter so many times until its processed? If you ran the 
code, my problems, as well as the intended goal, should become obvious. Also, 
why wouldn't someone who's willing to help me not run the code (takes a few 
seconds btw) I'm having trouble with in order to diagnose its faults, yet you 
have the time to write how you won't run it? If I did have a teacher to help 
me, this would be the last place I'd come to for help. It should be easy to 
deduce what I intended this program to do. Please no one respond being as I am 
done here, I just had to vent, but instead report it if you want.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replace blanks with letter

2013-08-22 Thread eschneider92
I wanted the program to stop only after all the letters were typed; why in the 
world would I try to write a program with blanks for each letter that seem 
intended to be filled, only to have it stop if the last letter is typed, or 
have to type each letter so many times until its processed? If you ran the 
code, my problems, as well as the intended goal, should become obvious. Also, 
why would someone who's willing to help me not run the code (takes a few 
seconds btw) I'm having trouble with in order to diagnose its faults, yet you 
have the time to write how you won't run it? If I did have a teacher to help 
me, this would be the last place I'd come to for help. It should be easy to 
deduce what I intended this program to do. Please no one respond being as I am 
done here, I just had to vent, but instead report it if you want. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replace blanks with letter

2013-08-21 Thread eschneider92
Thanks. I am running into a bunch of problems with the following code, all of 
which are clear when running the program

import random
letters='abcdefg' 
blanks='_'*len(letters) 
print('type letters from a to g')
print(blanks)
for i in range(len(letters)):
if letters[i] in input(): 
blanks = blanks[:i] + letters[i] + blanks[i+1:]
print(blanks)

If anyone could post an example of how to correctly code this, I would 
appreciate it. I can't seem to figure it out.

I'll definitely heed Fabio's advice for future reference, but I don't think 
it's related to the problems I'm currently experiencing. If it is, and I'm just 
not getting it (most likely the case), please post an example of how to 
implement his code advice in doing what I wish to accomplish here.
-- 
http://mail.python.org/mailman/listinfo/python-list


Replace blanks with letter

2013-08-20 Thread eschneider92
I'm trying to replace the blank(_) with the letter typed in by the user, in the 
appropriate blank(_) spot where the letter should be (where is in the letters 
list).

letters='abcdefg'
blanks='_ '*len(letters)
print('type letter from a to g')
print(blanks)
input1=input()
for i in range(len(letters)):
if letters[i] in input1:
blanks = blanks[:i] + letters[i] + blanks[i+1:]


What am I doing wrong in this code?

Thanks
Eric
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replace blanks with letter

2013-08-20 Thread eschneider92
Is there also a way to have the code remember what I typed and not stop after 
the first letter the user types? For example, if I typed 'a' once, thus 
returning 'a__', and then typed in 'b', I want the code to return 'ab_' 
and so on. I wasn't clear about this part in my original post. Thanks for the 
help.

Eric
-- 
http://mail.python.org/mailman/listinfo/python-list


.split() Qeustion

2013-08-13 Thread eschneider92
How can I use the '.split()' method (am I right in calling it a method?) 
without instead of writing each comma between words in the pie list in the 
following code? Also, is there a way to use .split instead of typing the 
apostrophes? Thank you.

import random
pie=['keylime', 'peach', 'apple', 'cherry', 'pecan']
print(random.choice(pie))

Eric
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: .split() Qeustion

2013-08-13 Thread eschneider92
It's obvious that the word 'without' in my first sentence was meant to be 
ommited, and it's a simple question. Thank Gary!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beginner question (True False help)

2013-08-09 Thread eschneider92
This is what I ended up with btw. Does this insult anyone's more well attuned 
Python sensibilities?

letters='abcdefghijkl'
def repeat():
print('wanna go again?')
batman=input()
if batman in ('y','yes'):
main()
else:
return
def main():
print('guess a letter')
batman=input()
if batman in letters:
print('ok that letter was in letters')
repeat()
else:
print('asdasdasd')
repeat()
main()
print('how ya doin')
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beginner question (True False help)

2013-08-09 Thread eschneider92
This is what I ended up with btw. Does this insult anyone's more well-attuned 
Pythonic sensibilities? 

letters='abcdefghijkl' 
def repeat(): 
print('wanna go again?') 
batman=input() 
if batman in ('y','yes'): 
main() 
else: 
return 
def main(): 
print('guess a letter') 
batman=input() 
if batman in letters: 
print('ok that letter was in letters') 
repeat() 
else: 
print('asdasdasd') 
repeat() 
main() 
print('how ya doin')
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beginner question (True False help)

2013-08-09 Thread eschneider92
I don't understand any of the advice any of you have given.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beginner question (True False help)

2013-08-09 Thread eschneider92
Thanks, though me not utilizing any of the other advice wasn't from lack of 
trying; I couldn't understand any of it. I get it now that I have a corrrect 
example code in front of me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beginner question (True False help)

2013-08-09 Thread eschneider92
What does global mean?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beginner question (True False help)

2013-08-09 Thread eschneider92
(I forgot to post this with my last post.) 
Also, I don't understand any part of the following example, so there's no 
specific line that's confusing me. Thanks for the help btw. 

var = 42 
def  myfunc(): 
 var = 90 

print before:, var 
myfunc() 
print after:, var 

def myfunc(): 
global var 
var = 90 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beginner question (True False help)

2013-08-09 Thread eschneider92
(I forgot to post this with my last post.)
Also, I don't understand any part of the following example, so there's no 
specific line that's confusing me. Thanks for the help btw.

var = 42 
def  myfunc(): 
 var = 90 

print before:, var 
myfunc() 
print after:, var 

def myfunc(): 
global var 
var = 90 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beginner question (True False help)

2013-08-09 Thread eschneider92
I'm sorry, but I still don't understand how it applies to my problem. Thanks 
for everyone's patience.
-- 
http://mail.python.org/mailman/listinfo/python-list


beginner question (True False help)

2013-08-07 Thread eschneider92
I'm trying to create an option for the program to repeat if the user types 'y' 
or 'yes', using true and false values, or otherwise end the program. If anyone 
could explain to me how to get this code working, I'd appreciate it.

letters='abcdefghijklmn'
batman=True
def thingy():
print('type letter from a to n')
typedletter=input()
if typedletter in letters:
print('yes')
else:
print('no')
def repeat():
print('go again?')
goagain=input()
if goagain in ('y', 'yes'):
print('ok')
else:
print('goodbye')
batman=False
while batman==True:
thingy()
repeat()
print('this is the end')
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beginner question (True False help)

2013-08-07 Thread eschneider92
What I wanted to happen is when the user typed something other than 'y' or 
'yes' after being asked 'go again?', the batman==False line would cause the 
program to stop asking anything and say 'this is the end'. Instead, what is 
happening is that the program just keeps going. I figured that after defining 
the function (thingy(), repeat()), that the while statement would repeat until 
the 'go again' user input was something other than 'y' or 'yes', and the 
batman==False part of the repeat() function would cause the 'while 
batman==True' part to become False and end. You probably answered my question 
and I'm too dumb to see it, but that's a slight elaboration on my problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Beginner question

2013-08-06 Thread eschneider92
Why won't the 'goodbye' part of this code work right? it prints 'ok' no matter 
what is typed. Much thanks.

def thing():
print('go again?')
goagain=input()
if goagain=='y' or 'yes':
print('ok')
elif goagain!='y' or 'yes':
print('goodbye')
sys.exit()
thing()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question

2013-08-06 Thread eschneider92
Thanks that helped a lot!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hangman question

2013-08-05 Thread eschneider92
Thanks I get it now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Hangman question

2013-08-04 Thread eschneider92
I'm  on chapter 9 of this guide to python: 
http://inventwithpython.com/chapter9.html but I don't quite understand why 
line 79 is what it is (blanks = blanks[:i] + secretWord[i] + blanks[i+1:]). I 
particularly don't get the [i+1:] part. Any additional information and help 
would be greatly appreciated!
-- 
http://mail.python.org/mailman/listinfo/python-list


Print word from list

2013-08-03 Thread eschneider92
pie='apple keylime pecan meat pot cherry'
pie.split()

How can I print a word from the list other than this way:  print(pie[0:5])  ?

Thanks in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Print word from list

2013-08-03 Thread eschneider92
Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple program question.

2013-06-11 Thread eschneider92
No.
-- 
http://mail.python.org/mailman/listinfo/python-list


Simple program question.

2013-06-09 Thread eschneider92
How do I make it so I only have to type in 'parry' once?

import random
words=['hemisses', 'hestabsyou']
randomizer=random.choice(words)
if input()!=('duck', 'parry'):
print('try again')
if input()=='duck':
print(randomizer)
if randomizer=='hemisses':
results=['you should have ran', 'you win']
randomresult=random.choice(results)
print('do you wanna run or fight?')
if input()=='fight':
print(randomresult)
sys.exit()
if randomizer=='hestabsyou':
print('you done fail')
sys.exit()
words2=['you parry his blow', 'he stabs you right behind the clavicle']
randomizer2=random.choice(words2)
if input()=='parry':
print(randomizer2)
if randomizer2=='you parry his blow':
results2=['you should have run away', 'you wins!']
randomresult2=random.choice(results2)
print('do you wanna run or fight?')
if input()=='fight':
print(randomresult2)
sys.exit()
if randomizer2=='he stabs you right behind the clavicle':
print('Clavicle stab does 100 damage')
sys.exit()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question

2013-06-05 Thread eschneider92
Thanks everyone!
-- 
http://mail.python.org/mailman/listinfo/python-list


Beginner question

2013-06-03 Thread eschneider92
Is there a more efficient way of doing this? Any help is gratly appreciated.


import random
def partdeux():
print('''A man lunges at you with a knife!
Do you DUCK or PARRY?''')
option1=('duck')
option2=('parry')
optionsindex=[option1, option2]
randomizer=random.choice(optionsindex)
while randomizer==option1:
if input() in option1:
print('he tumbles over you')
break
else:
print('he stabs you')
break
while randomizer==option2:
if input() in option2:
print('you trip him up')
break
else:
print('he stabs you')
break
partdeux()
-- 
http://mail.python.org/mailman/listinfo/python-list


repeat program

2013-04-29 Thread eschneider92
How do I make the following program repeat twice instead of asking whether the 
player wants to play again?


import random
import time

def intro():
print('You spot 2 caves in the distance.')
print ('You near 2 cave entrances..')
time.sleep(1)
print('You proceed even nearer...')
time.sleep(1)

def choosecave():
cave=''
while cave!='1' and cave !='2':
print('which cave?(1 or 2)')
cave=input()
return cave

def checkcave(chosencave):
friendlycave=random.randint(1,2)
if chosencave==str(friendlycave):
print ('you win')
else:
print('you lose')

playagain='yes'
while playagain=='yes':
intro()
cavenumber=choosecave()
checkcave(cavenumber)
print('wanna play again?(yes no)')
playagain=input()

Thanks in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Guess the Number Repeat

2013-04-25 Thread eschneider92
How do I make the following program play the 'guess the number game' twice?

import random
guessesTaken = 0
print('Hello! What is your name?')
myName = input()
number = random.randint(1, 20)
print('Well, ' + myName + ', I am thinking of a number between 1 and 20.')
while guessesTaken  6:
print('Take a guess.') 
guess = input()
guess = int(guess)
print('You have ' + str(5 - guessesTaken) + ' guesses left.')
guessesTaken = guessesTaken + 1
if guess  number:
print('Your guess is too low.')
if guess  number:
print('Your guess is too high.')
if guess == number:
break
if guess == number:
guessesTaken = str(guessesTaken)
print('Good job, ' + myName + '! You guessed my number in ' + guessesTaken 
+ ' guesses!')
if guess != number:
number = str(number)
print('Nope. The number I was thinking of was ' + number)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-11 Thread eschneider92
How do I make it say that I have one game left? I'm having trouble fitting it 
into my main code. Thanks a lot for the help btw.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-11 Thread eschneider92
The 2 makes the game play twice instead of 3 times, right? I've tried it with 
the 1, but but I'm still having trouble. Again, to be exact, I want to somehow 
make it count down from 2 (the number of games)and print. If that's what this 
does, is it possible to insert it into my original main program?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-11 Thread eschneider92
If you get the time, please post an example, because I don't understand.
-- 
http://mail.python.org/mailman/listinfo/python-list


guessthenumber print games left

2013-04-10 Thread eschneider92
Could anyone tell me how to make the program tell me how many games are left 
before the first game and second game? For example, after one game of guess the 
number, I want it to tell me that i get one more game. P.S. I'm totally new to 
python (obviously), and I just added numberofgames variable in hopes of solving 
this problem. am I on the right track? Thanks for any assistance!
numberofgames=1
while numberofgames4:
numberofgames=numberofgames+2
import random
print ('type name')
name=input()
print ('guess a number between 1 and 20, ' + name)
number=random.randint(1,20)
guessestaken=0
while guessestaken5:
guessestaken=guessestaken+1
guess=input()
guess=int(guess)
if guessnumber:
print ('your guess is too low')
if guessnumber:
print ('your guess is too high0')
if guess==number:
break
if guess==number:
print ('you win!')
if guess!=number:
number=str(number)
print ('you lose. the number was ' + number)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread eschneider92
On Wednesday, April 10, 2013 5:44:20 AM UTC-4, Chris Angelico wrote:
 On Wed, Apr 10, 2013 at 7:39 PM,  eschneide...@comcast.net wrote:
 
  Could anyone tell me how to make the program tell me how many games are 
  left before the first game and second game? For example, after one game of 
  guess the number, I want it to tell me that i get one more game. P.S. I'm 
  totally new to python (obviously), and I just added numberofgames variable 
  in hopes of solving this problem. am I on the right track? Thanks for any 
  assistance!
 
 
 
  numberofgames=1
 
  while numberofgames4:
 
  numberofgames=numberofgames+2
 
 
 
 First off, why are you adding two? Is this a typo?
 
 
 
 You have here a counter, but it's counting up. To figure out how many
 
 games are left, just subtract the numberofgames from the total number
 
 of games that you'll be allowing - that's how many there are left. Do
 
 you know how to do that?
 
 
 
 ChrisA

Thanks for the quick reply. I've been trying your advice but I can't figure it 
out. If anyone could show me how to do it in program form, it would be much 
obliged.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread eschneider92
On Wednesday, April 10, 2013 5:39:23 AM UTC-4, eschne...@comcast.net wrote:
 Could anyone tell me how to make the program tell me how many games are left 
 before the first game and second game? For example, after one game of guess 
 the number, I want it to tell me that i get one more game. P.S. I'm totally 
 new to python (obviously), and I just added numberofgames variable in hopes 
 of solving this problem. am I on the right track? Thanks for any assistance!
 
 numberofgames=1
 
 while numberofgames4:
 
 numberofgames=numberofgames+2
 
 import random
 
 print ('type name')
 
 name=input()
 
 print ('guess a number between 1 and 20, ' + name)
 
 number=random.randint(1,20)
 
 guessestaken=0
 
 while guessestaken5:
 
 guessestaken=guessestaken+1
 
 guess=input()
 
 guess=int(guess)
 
 if guessnumber:
 
 print ('your guess is too low')
 
 if guessnumber:
 
 print ('your guess is too high0')
 
 if guess==number:
 
 break
 
 if guess==number:
 
 print ('you win!')
 
 if guess!=number:
 
 number=str(number)
 
 print ('you lose. the number was ' + number)

I can't figure out how to make it count down by itself and state how many are 
left.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: guessthenumber print games left

2013-04-10 Thread eschneider92
(Didn't mean to post the last bit.) Is this possibly what you meant? If it is I 
still can't figure out how to apply it to the guessthenumber program. 
numberofgames=1 
while numberofgames4: 
numberofgames=numberofgames+2
print (4-numberofgames)
if numberofguesses3:
print(numberofgames)
-- 
http://mail.python.org/mailman/listinfo/python-list