1 Replies - 791 Views - Last Post: 27 November 2012 - 10:18 AM Rate Topic: -----

#1 ravit5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-November 12

Wrong input needs to restart, Problem

Posted 27 November 2012 - 09:45 AM

Here is my code straight out of python:

a = input("What should i do? Cave(1) or the forest(2)")
if a == '1':
        print("you walk into the cave, with no way of seeing in the dark abyss you fall, maybe 10 or 20 feet. your legs break on impact. you slowly bleed out and die.")
        print ("Too bad, maybe the woods is a better area. Try again, wont you?")

if a == '2':
    print("You walk into the forest, you still have a feeling like you're being watched. you find an axe beside a giant oak tree. what to do?")

So if a = 1 i want the program to restart and ask (a) again
we use pyscripter in out school, thats why its not just regular pyshell

This post has been edited by Simown: 27 November 2012 - 10:07 AM
Reason for edit:: Code tags!

Is This A Good Question/Topic? 0
  • +

Replies To: Wrong input needs to restart, Problem

#2 Nallo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 165
  • View blog
  • Posts: 258
  • Joined: 19-July 09

Re: Wrong input needs to restart, Problem

Posted 27 November 2012 - 10:18 AM

You need to put your code in a loop, that is only left when the user inputs "2":

code is below, but before looking you should try yourself.

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1