2 Replies - 1070 Views - Last Post: 08 October 2012 - 11:42 PM Rate Topic: -----

#1 ReconWo1f   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-October 12

Number Game code (its impossible to win )

Posted 08 October 2012 - 01:33 PM

import random
import sys

print ("hi")

enter = "Please press Enter to continue!"

print ("Hello! welcome to the Ninja Master Gordon number Guessing game!")
print ("Please Guess the Black Ninja clan's number between 1 - 100!")
computernum = random.randint (1,1)
Guess1 = input("My First Guess Is: ")
if Guess1 == computernum:
    print ("You have defeated the Black Ninja Clan! you are a WINNER!!!")
    input (enter)
    sys.exit(0)
else:
    print ("sorry, please try again")
    print ("YOU HAVE ONLY TWO GUESSES REMAINING!")
    Guess2 = input ("My second Guess Is: ")
if Guess2 == computernum:
    print ("You have defeated the Black Ninja Clan! you are a WINNER!!!")
    input (enter)
    sys.exit(0)
else:
    print ("sorry , please try again")
    print ("YOU HAVE ONLY ONE GUESS LEFT make it count...")
    Guess3 = input ("My Final Guess Is: ")
if Guess3 == computernum:
    print ("You have defeated the Black Ninja Clan! you are a WINNER!!!")
    input (enter)
    sys.exit(0)
else:
    print ("YOU LOST AT THIS GAME!!! but dont let the Diamond Ninja Force down have another GO!")
    computernum = str(computernum)
    print ("The Black ninja clan's number was "+computernum)
    input (enter)
    sys.exit (0)


Its impossible to win and I cant find the error I thinks its because of the == section and Im using python 3.3

This post has been edited by Simown: 08 October 2012 - 01:41 PM
Reason for edit:: USE CODE TAGS!


Is This A Good Question/Topic? 0
  • +

Replies To: Number Game code (its impossible to win )

#2 NathanMullenax   User is offline

  • D.I.C Head
  • member icon

Reputation: 103
  • View blog
  • Posts: 218
  • Joined: 23-September 12

Re: Number Game code (its impossible to win )

Posted 08 October 2012 - 01:54 PM

It looks like the input is a string rather than an integer. If you wrap the input statements in int() like:

GuessN = int(input("Guess N:"))



It works. Hope this helps. The odds of winning will still be really low, though: 3/100.
Was This Post Helpful? 2
  • +
  • -

#3 ReconWo1f   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-October 12

Re: Number Game code (its impossible to win )

Posted 08 October 2012 - 11:42 PM

THANK YOU you are so much help and I'm so grateful for contribution :)!!!!!!!!!!!!!!!!!!!!!!
:^: :^: :^:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1