Jun-07-2017, 05:51 PM
Hello,
Personal background:
My first forum post, teaching myself programming, and teaching myself python so please be patient with me.
Program Background:
I am working on recreating the Oregon Trail in Python from Basic.
My source for the code is page 135 of creative computing magazine May edition 1978 accessed from archive.org website
Question (stems from around line 100):
How do I create force the user to input an integer 1-5?
(I am early in the stages of rewriting the program so please offer any suggestions to help a novice)
Personal background:
My first forum post, teaching myself programming, and teaching myself python so please be patient with me.
Program Background:
I am working on recreating the Oregon Trail in Python from Basic.
My source for the code is page 135 of creative computing magazine May edition 1978 accessed from archive.org website
Question (stems from around line 100):
How do I create force the user to input an integer 1-5?
(I am early in the stages of rewriting the program so please offer any suggestions to help a novice)
# This is a python version of the Oregon Trail. # The code was published in creative computing magazine # in the May/June issue from 1978. # The original code appears to be BASIC. # Programming is done by Mark R. Weems as part of his # attempt to self learn programming with Python being # one of the languages he is learning. ## Original Code includes intro... ## Program name - Oregon Version:01/01/78 ## Original programming by Bill Heinemann - 1971 ## Support research and materials by Don Ravitsch ## Minnesota Educational Computing Consortium Staff ## CDC Cyber 70/73-26 BASIC 3.1 ## Documentation booklet 'Oregon' available from ## MECC Support Services ## 2520 Broadway Drive ## St. Paul, MN 55113 # Meanings of variables used will be noted prior to variable print (""" Do you need instructions? 1 Yes 2 No """) # C5 was the original code for yes/no responses to questions # Here I will keep C5 as the variable C5 = int(input()) while C5 == 1: print (""" ***Instructions*** This program simulates a trip over the Oregon Trail from Independence, Missouri to Oregon city, Oregon in 1847. Your family if five will cover the 2040 mile Oredon Trail in 5-6 months --- if you make it alive. You had saved $900 to spend for the trip, and you've just paid $200 for a wagon. You will need to spend the rest of your money on the following items: Oxen - You can spend $200-$300 on your team The more you spend, the faster you will go because you will have better animals. Food - The more you have, The less chance there is of getting sick. Ammunition - $1 buys a belt of 50 bullets. You will need bullets for attacks by animals and bandits, and for hunting food. Clothing - This is especially important for the cold weather you will encounter when crossing the mountains. Miscellaneous Supplies - This includes medicine and other things you will need for sickness and emergency repairs. You can spend all your money before you start your trip - or you can save some of your cash to spend at Forts along the way when you run low. However, items cost more at the Forts. You can also go hunting along the way yo get more food. Whenever you have to use your trusty rifle along the way, you will be told to type a word (one that sounds like a gun shot). The faster you type the word and hit the ***Enter*** key, the better luck you'll have with your gun. At each turn, all items are shown in Dollar amounts except bullets. When asked to enter money amounts, don't use **$**. Good Luck! """) # Now to break the loop that is created if the user types 1 C5 = 0 print (""" How good a shot are you with a rifle? 1. Ace Marksman 2. Good Shot 3. Fair Middlin' 4. Need More Practice 5. Shaky Knees Enter one of the above -- The better you claim you are, the faster you'll have to be with your gun to be successful. """) # D9 is the coice of shooting expertise level D9 = int(input()) # Create something to force a correct input VC1 = [1, 2, 3, 4, 5] while D9 != VC1: print ("That is not a correct value. Try again.") D9 = int(input()) else: print ("You selected", D9)