Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Python-Chatbot/BTC_AND_GOLD.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
25 lines (22 sloc)
991 Bytes
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
import requests | |
ui_bitcoin = ["bitcoin", "bitcoin price"] | |
ui_gold = ["gold", "gold price"] | |
bye = ["bye", "goodbye", ""] | |
def ui(enter): | |
for word in ui_bitcoin: | |
if enter.lower().strip() == word.lower().strip(): | |
bit = requests.get('https://api.coindesk.com/v1/bpi/currentprice.json') | |
print ('₤' + bit.json()['bpi']['GBP']['rate'] + " For 1 BTC") | |
return bit | |
for worn in ui_gold: | |
if enter.lower().strip() == word.lower().strip(): | |
gold = requests.get('http://gold-feed.com/paid/d7d6s6d66k4j4658e6d6cds638940e/all_metals_json_usd.php') | |
print ('₤' + (gold.json()['gold_londonfix_pm']) + " Per 10 grams of 14K gold") | |
for word in bye: | |
if enter.lower().strip() == word.lower().strip(): | |
gbye = ("Thank you for using our service!") | |
print(gbye) | |
exit() | |
return gbye | |
while True: | |
ui(input("Please enter Bitcoin or Gold: ")) |