-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."}]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |