-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoke_picker.py
More file actions
65 lines (53 loc) · 1.41 KB
/
poke_picker.py
File metadata and controls
65 lines (53 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/python3
'''Keystone Learning | Author: Paul Lack
Demonstrating a method to present a menu on the command line using
a while loop. Menu options let you get information about Pokemons
from the pokeapi.co API.'''
import time
import requests
OPTION_1 = '1. View ability info by name.'
OPTION_2 = '2. Quit.'
OPTION_SUB_1 = ''
lines = '*'*50
title = 'Welcome to Pokemon Info!'
instruction_1 = 'Please make a selection.'
def show_main_menu():
print(lines)
print(title)
print(lines)
print(OPTION_1)
print(OPTION_2)
print(lines)
def show_submenu_1():
print(lines)
print(instruction_1)
print(lines)
print(OPTION_SUB_1)
def get_abilities():
choice = input('Enter the name of the Pokemon you wish to know about. >>> ')
BASE_URL = 'https://pokeapi.co/api/v2/ability/'
response = requests.get(BASE_URL + choice).json()
print(response)
print('\n'*3)
def exit_program():
print('Exiting gracefully in...')
time.sleep(1)
print('3')
time.sleep(1)
print('2')
time.sleep(1)
print('1')
time.sleep(1)
print('Goodbye!')
def main():
choice = ''
while choice != 2:
show_main_menu()
choice = int(input('Please type your selection. >>> '))
if choice == 1:
show_submenu_1()
if choice == 1:
get_abilities()
exit_program()
if __name__ == "__main__":
main()