Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python help thread?
#4
This part is incorrect: "if n != randint(1,20)" What you're doing here is comparing n which is what they've entered to an random number. You should compare this to "num" which you generated at the beginning of the script.

Also it looks like you've only asked the user for the number ONCE but "tried" to evaluate it 3 times with if statements incorrectly.


This is what I think that would work...

from random import randint

num = randint(1,20)

for i in range(1, 4):
def zenumbers(n):
if n != num
print "Guess again!"
else
print "you got it!"
break
else:
print "Used up all 3 guesses"
Reply


Messages In This Thread
Python help thread? - by Alley - 2011-02-12, 10:05 PM
Python help thread? - by Derosis - 2011-02-12, 10:09 PM
Python help thread? - by Erebus - 2011-02-12, 10:18 PM
Python help thread? - by XTOTHEL - 2011-02-12, 10:23 PM
Python help thread? - by Alley - 2011-02-12, 10:25 PM
Python help thread? - by XTOTHEL - 2011-02-12, 10:28 PM
Python help thread? - by Alley - 2011-02-12, 10:30 PM
Python help thread? - by XTOTHEL - 2011-02-12, 10:46 PM
Python help thread? - by Alley - 2011-02-12, 11:04 PM
Python help thread? - by XTOTHEL - 2011-02-12, 11:19 PM
Python help thread? - by Eos - 2011-02-12, 11:45 PM
Python help thread? - by XTOTHEL - 2011-02-12, 11:52 PM
Python help thread? - by Eos - 2011-02-13, 12:21 AM
Python help thread? - by XTOTHEL - 2011-02-13, 12:27 AM
Python help thread? - by Alley - 2011-02-13, 01:34 AM
Python help thread? - by Eos - 2011-02-13, 09:13 AM
Python help thread? - by ThatWasMyKil - 2011-02-16, 12:16 AM
Python help thread? - by AngelSL - 2011-03-01, 10:49 AM
Python help thread? - by EarthAdept2 - 2011-03-04, 04:53 PM
Python help thread? - by JPTheMonkey - 2011-03-04, 06:05 PM
Python help thread? - by EarthAdept2 - 2011-03-04, 06:09 PM
Python help thread? - by Fiel - 2011-03-05, 08:22 AM
Python help thread? - by JPTheMonkey - 2011-03-05, 09:38 PM
Python help thread? - by Fiel - 2011-03-06, 03:35 AM
Python help thread? - by EarthAdept2 - 2011-03-14, 02:19 AM
Python help thread? - by XTOTHEL - 2011-03-14, 02:30 AM
Python help thread? - by EarthAdept2 - 2011-03-14, 03:30 AM
Python help thread? - by JPTheMonkey - 2011-03-30, 07:44 PM
Python help thread? - by Fiel - 2011-03-30, 07:47 PM
Python help thread? - by JPTheMonkey - 2011-03-30, 10:16 PM
Python help thread? - by Alley - 2011-03-30, 11:58 PM
Python help thread? - by Fiel - 2011-04-01, 11:45 PM
Python help thread? - by Nikkey - 2011-04-02, 12:51 PM
Python help thread? - by JPTheMonkey - 2011-04-06, 11:46 PM
Python help thread? - by Alley - 2011-04-12, 10:58 PM
Python help thread? - by XTOTHEL - 2011-04-12, 11:13 PM
Python help thread? - by JPTheMonkey - 2011-04-12, 11:18 PM
Python help thread? - by Fiel - 2011-04-12, 11:20 PM
Python help thread? - by Alley - 2011-04-13, 12:50 AM
Python help thread? - by Fiel - 2011-04-13, 01:08 AM
Python help thread? - by Alley - 2011-04-13, 01:25 AM
Python help thread? - by Fiel - 2011-04-13, 01:31 AM
Python help thread? - by Alley - 2011-04-13, 01:34 AM
Python help thread? - by Fiel - 2011-04-13, 01:37 AM
Python help thread? - by Alley - 2011-04-13, 01:44 AM
Python help thread? - by Fiel - 2011-04-13, 01:59 AM
Python help thread? - by Alley - 2011-04-13, 02:02 AM
Python help thread? - by Fiel - 2011-04-13, 02:05 AM
Python help thread? - by Alley - 2011-04-13, 02:07 AM
Python help thread? - by JPTheMonkey - 2011-04-13, 02:27 AM
Python help thread? - by Alley - 2011-04-13, 10:17 AM
Python help thread? - by JPTheMonkey - 2011-04-13, 04:17 PM
Python help thread? - by EarthAdept2 - 2011-04-18, 07:01 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)