-2

Here is my complete code:

import sys
import string

version = 1.0
print ("...Written in Python 3.4...\n")
print ("Copyright 2014 Ethan Gold. version 1.0")
print ("\n")
print ("Welcome to BattleText!")
print ("Is this your first time playing?")
#functions:



            #Story Select
def storySelect(sys, string):
    print ("\n Story Select: 1: Beta Framework")
    yn0 = input("> ")
    if yn0 == 1:
        betFrame(sys, string)

            #Beta Framework
def betFrame(sys, string):
    print ("test")


yn = input("> ")
if yn == "y":
    print ("\n Welcome to the world of BattleText!")
    print ("BT is a combat-based text adventure platform that supports multiple stories")
    print ("In this game, you win by defeating all enemies. You lose if your health drops to 0\n")
    print ("This is version", version)
    if version == 1.0:
        print ("This version of BattleText does not support third party or patchable stories")
        print ("BTv1.0 is a demo and all stories are distributed through official updates")
        print ("This is a test beta framework")
    else:
        print ("This version of BT should support third-party and patchable stories")

else:
    storySelect(sys, string)

The part where the problem is occuring is here:

#Story Select
    def storySelect(sys, string):
        print ("\n Story Select: 1: Beta Framework")
        yn0 = input("> ")
        if yn0 == 1:
            betFrame(sys, string)

                #Beta Framework
    def betFrame(sys, string):
        print ("test")

when storySelect is called, it is supposed to ask you to chose from a list. When you type 1 it should call betFrame, but it dosent seem to be doing that. instead, when i type 1, it just goes blank and the program exits with no errors. Please help!

1 Answers1

3

input returns a string. You are comparing this to an integer, so the expression will never be true. You need to convert the input to an int (or compare to a string).

yn0 = input("> ")
if yn0 == "1":
    # do stuff


yn0 = int(input("> ")) # Also consider catching a ValueError exception
if yn0 == "1":
    # do stuff
Tim
  • 11,710
  • 4
  • 42
  • 43
  • 1
    [This community wiki](http://stackoverflow.com/a/23294659/3001761) is useful for adding input validation. – jonrsharpe Jun 08 '14 at 07:17