-
Notifications
You must be signed in to change notification settings - Fork 0
/
r.py
31 lines (25 loc) · 936 Bytes
/
r.py
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
import requests
def dapatkan_ayat(surah, ayat):
base_url = f"https://api.alquran.cloud/v1/ayah/{surah}:{ayat}/editions/quran-uthmani,id.indonesian"
response = requests.get(base_url)
data = response.json()
if response.status_code == 200 and data['status'] == 'OK':
ayat_arabic = data['data'][0]['text']
ayat_indo = data['data'][1]['text']
return {
"Arabic": ayat_arabic,
"Indonesian": ayat_indo
}
else:
return "Gagal mengambil ayat atau ayat tidak ditemukan."
def main():
surah = input("Masukkan nomor surah: ")
ayat = input("Masukkan nomor ayat: ")
ayat_info = dapatkan_ayat(surah, ayat)
if isinstance(ayat_info, dict):
print(f"Ayat dalam Bahasa Arab: {ayat_info['Arabic']}")
print(f"Ayat dalam Bahasa Indonesia: {ayat_info['Indonesian']}")
else:
print(ayat_info)
if __name__ == "__main__":
main()