python text based game code example
Example 1: how to make text game python
import time
print('CoolKitty Presents')
time.sleep(2)
print('Text Game')
print('1 Start')
print('2 Exit')
start = int(input('Press Binded Number'))
if start == 1:
print('Go To Place 1 Or Place 2?')
place = int(input('Place 1 Or Place 2?'))
if place == 1:
print('You are at place 1')
exit()
if place == 2:
print('You are at place 2')
exit()
if start == 2:
exit()
Example 2: text based game python
x1=0
x2=0
x3=0
x4=0
x5=8
x6=0
x7=0
x8=0
x9=0
for x in "banana":
print(x1, x2, x3)
print(x4, x5, x6)
print(x7, x8, x9)
ducky=input("what to do ")
if ducky == "left":
x6=8
x5=0
print('\033[H\033[J', end='')
Example 3: python naming script text game
def get_name():
print("Hello what is your name?")
name = input("My name is: ")
print("Hello ", name)
return name