Skip to content

Commit bbd6c22

Browse files
committed
..
1 parent 56a33da commit bbd6c22

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

__pycache__/indeed.cpython-39.pyc

891 Bytes
Binary file not shown.

homework4.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
4+
print("Hello, please choose select a country by number:")
5+
6+
result = requests.get("https://www.iban.com/currency-codes")
7+
soup = BeautifulSoup(result.text, "html.parser")
8+
tr = soup.find_all('tr')
9+
tds = soup.find_all('td')
10+
11+
data = []
12+
13+
for tr in soup.find_all('tr'):
14+
tds = list(tr.find_all('td'))
15+
if tr.find_all('td'):
16+
country = tds[0].text
17+
currency = tds[1].text
18+
code = tds[2].text
19+
number = tds[3].text
20+
data.append([country,currency,code,number])
21+
22+
for i in range(len(data)):
23+
print(f"# {i+1}", data[i][0])
24+
i+=1
25+
26+
def answer():
27+
try:
28+
answer_1 = int(input("Where are you from? Choose a country by number.\n #:"))
29+
if 0 < answer_1 < 269:
30+
print(data[answer_1-1][0])
31+
elif answer_1 <1 or answer_1>268:
32+
print("Choose from a number list.")
33+
answer()
34+
except:
35+
print("This is not a number.")
36+
answer()
37+
38+
return answer_1
39+
40+
answer()

0 commit comments

Comments
 (0)