I am making a game as a programmer that has only worked with python for about 2 months, and I need a way to save data. I know about pickle, but the Documentation does not help at all. Please note that I am using 3.1.1, so don't give me answers for python 2.x. Here is some of the code (Also note that I have used underscores were I need help):
import time
import pickle
import random
#town 1 is Marata, town 2 Khmerville, 3 rome, 4 babel, and 5 is Startville
def saveConduct():
_______________________
____________________________
def townselect():
print('Which town would you like to go to?')
print('Marata (1), khmerville (2), Rome (3), or Babel (4)?')
if input() == '1':
print('See Marata, a prosperous City. Shop here?')
if input() == 'yes' or 'Yes' or 'y' or 'Y':
print('Your options are:')
print('Pork(p), $15 a pound')
print('Fertilizer(f), $12 a pound')
print('Tulip Bulbs(t), 6000 florins a pound')#A Little Joke
if input() == 'p':
print('What quantity? 1, 10, or 50?')
if input() == '1':
money = money - 15
goodspace = goodspace - 1
print('your balance is ' , money)
Pork = 1
elif input() == '10':
money == money - 150
goodspace = goodspace - 10
print('Your balance is' , money)
Pork = 10
else:
money = money - 750
goodspace = goodspace - 50
print ('Your balance is ' , money)
Pork = 50
elif input() == 's':
print('What Quantity? 1, 10, or 50?')
if input() == '1':
money = money - 100
print (money)
elif input() == '10':
money = money - 1000
goodspace = goodspace - 10
print('your balance is ' , money)
elif input() == '50' and money >= 5000:
money = money - 5000
goodspace = goodspace - 50
print ('Your balance' , money)
elif input is '50' and money < 5000:
print("You don't have enough money for that!")
playing = False
elif input() == 'S':
print('What Quantity? 1, 10, or 50?')
if input() == '1':
money = money - 1500
goodspace = goodspace - 1
print ('Your balance' , money)
Spice = 1
elif input == '10' and money >= 15000:
money = money - 15000
goodspace = goodspace - 10
Spice = 10
print ('Your balance' , money)
elif input() == 50 and money >= 75000:
money = money - 75000
goodspace = goodspace - 50
print ('Your balance' , money)
else:
print("Dude, Work on yur speleing.")
print('I CAN spele, jest so u no')
print("NOW I'm spelling stuff correctly.")
time.sleep(1)
quit
def game():
money = 5000
goodspace = 50
playing = True
print('Good. lets start the game\n\
But First, a Note: 1$ = 60 Florins in game.')#---IMPORTANT---#
time.sleep(3)
print('You are a poor man,')
print('Trying to make a fortune.')
time.sleep(1)
print('You start with $5000,')
print('And your goal is $1,000,000.')
time.sleep(1)
print('You can choose between 3 difficultys.')
time.sleep(1)
print('These difficultys are:')
print('Easy (e), medium (Unavailable), and hard(Unavailable). choose one.')
if input() == 'e':
print('You have selected easy mode. In this mode, there are less disasters')
time.sleep(1)
print('Ready...')
time.sleep(1)
print('Set...')
time.sleep(1)
print('GO!')
print("You're in a shop. Would you like to buy something?")
if input() == 'yes' or 'Yes' or 'y' or 'Y':
town = '1'
print('your options are:')
print('Wool(w), $10 a pound')
print('Sugar(s), $100 a pound')
print('Spices(S), $1500 a pound')
if input() == 'w':
print('What quantity? 1, 10, or 50?')
if input() == '1':
money = money - 10
goodspace = goodspace - 1
print('your balance is ' , money)
elif input() == '10':
money == money - 100
goodspace = goodspace - 10
print('Your balance is' , money)
else:
money = money - 500
goodspace = goodspace - 50
print ('Your balance is ' , money)
elif input() == 's':
print('What Quantity? 1, 10, or 50?')
if input() == '1':
money = money - 100
print (money)
elif input() == '10':
money = money - 1000
goodspace = goodspace - 10
print('your balance is ' , money)
elif input() == '50' and money >= 5000:
money = money - 5000
goodspace = goodspace - 50
print ('Your balance' , money)
elif input is '50' and money < 5000:
print("You don't have enough money for that!")
playing = False
elif input() == 'S':
print('What Quantity? 1, 10, or 50?')
if input() == '1':
money = money - 1500
goodspace = goodspace - 1
print ('Your balance' , money)
elif input == '10' and money >= 15000:
money = money - 15000
goodspace = goodspace - 10
print ('Your balance' , money)
elif input() == 50 and money >= 75000:
money = money - 75000
goodspace = goodspace - 50
print ('Your balance' , money)
else:
print("Dude, Work on yur speleing.")
print('I CAN spele, jest so u no')
print("NOW I'm spelling stuff correctly.")
time.sleep(1)
quit
elif input() == 'no':
townselect
print("Save Game?")
if input() == 'yes':
This is the point were I want to use a variable.