Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bsoyka authored Sep 22, 2018
1 parent ac8e73a commit 6b49d85
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[["Red","Yellow","Green","Blue"],{"1":"You will learn a lot today.","2":"Your shoes will make you happy today.","5":"You are very talented in many ways.","6":"It's better to be alone sometimes."},{"3":"A dream you have will come true.","4":"Now is the time to learn something new.","7":"The man on top of the mountain did not fall there.","8":"Sometimes you just need to lay on the floor."}],[["Red","Yellow","Green","Blue"],{"1":"If you're happy, you're successful.","2":"You will always be surrounded by true friends.","5":"Conquer your fears or they will conquer you.","6":"Rivers need springs."},{"3":"A lifetime of happiness is in store for you.","4":"Everything happens for a reason.","7":"The world may be your oyster, but that doesn't mean you'll get it's pearl.","8":"Do not fear what you don't know."}]]
13 changes: 13 additions & 0 deletions fortune_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def represents_int(string):
"""Used to check if str can be turned into an int
Args:
string - String to test
Returns:
True - string represents an int
False - string does not represent an int
"""
try:
int(string)
return True
except ValueError:
return False
67 changes: 67 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import random, json, fortune_helper
with open("data.json") as file:
fortune_tellers = json.load(file)
fortune_teller_number = random.choice(range(len(fortune_tellers)))
print("Fortune Teller #{}".format(fortune_teller_number + 1))
fortune_teller = fortune_tellers[fortune_teller_number]
pos_0 = fortune_teller[0]
pos_1 = fortune_teller[1]
pos_2 = fortune_teller[2]
pos = 0
print("")
for color in pos_0:
print(color)
print("")
user_input = None
while user_input not in pos_0:
user_input = input("Choose an option above, type exactly as shown: ")
if fortune_helper.represents_int(user_input):
amount_to_move = int(user_input)
else:
amount_to_move = len(user_input)
for _ in range(amount_to_move):
pos += 1
if pos == 3:
pos = 1
print("")
if pos == 1:
for number in pos_1:
print(number)
elif pos == 2:
for number in pos_2:
print(number)
print("")
user_input = None
if pos == 1:
while user_input not in pos_1:
user_input = input("Choose an option above, type exactly as shown: ")
elif pos == 2:
while user_input not in pos_2:
user_input = input("Choose an option above, type exactly as shown: ")
if fortune_helper.represents_int(user_input):
amount_to_move = int(user_input)
else:
amount_to_move = len(user_input)
for _ in range(amount_to_move):
pos += 1
if pos == 3:
pos = 1
print("")
if pos == 1:
for number in pos_1:
print(number)
elif pos == 2:
for number in pos_2:
print(number)
print("")
user_input = None
if pos == 1:
while user_input not in pos_1:
user_input = input("Choose an option above, type exactly as shown: ")
print("Your fortune is:")
print(pos_1[user_input])
elif pos == 2:
while user_input not in pos_2:
user_input = input("Choose an option above, type exactly as shown: ")
print("Your fortune is:")
print(pos_2[user_input])

0 comments on commit 6b49d85

Please sign in to comment.