Python indentation error

Asked

Viewed 1,392 times

3

I am new in Python and I am doing a project... however I was running this and gave an error in line 44, whose message is:

Indentationerror: expected an indented block

    import blockchain, threading, requests

coins_API = ["https://www.mercadobitcoin.net/api/BTC/ticker/", "www.exemplo.com", "www.exemplo.com"]
cc_names = ["Bitcoin", "Litecoin", "Etherum"]
btc_prices = []
ltc_prices = []
eth_prices = []

class wallet:
    def start():
        print("Starting BitBot!")

        prices.start()

        WALLETID = raw_input("Insert the Wallet ID: ")
        PASSWORD = raw_input("Insert your passoword: ")
        HOST = "https://blockchain.info"

        #checking_coin_prices.start()
        wallet_conn(WALLETID, PASSWORD, HOST)

    def wallet_conn(WALLETID, PASSWORD, HOST):
        try:
            print("Trying the connection with the wallet: ")
            current_wallet = wallet(WALLETID, PASSWORD, HOST)
        except:
            print("Login Unknown error!")

class prices:
    def start():
        print("Searching for prices!")
        while 1:
            for i in range(0, len(cc_names)):
                if i == 0:
                    btc_prices.append(get_cc_price())
                if i == 1:
                    ltc_prices.append(get_cc_price())
                if i == 2:
                    eth_prices.append(get_cc_price())

            if btc_prices >= eth_prices:
                #To do buy and sell prices!

    def get_cc_price(): #Erro de identação aqui! <-----------------------------
        for i in range(0, len(cc_names)):
            print("Checking the {} price!", .format(cc_names[i]))
            try:
                cc_price = requests.get(coins_API[i])
                print(cc_price.status_code)
                print(cc_price.json())
                if i == 0:
                    return conversions.usd_to_brl(cc_price["last"])
                else:
                    return conversions,usd_to_brl(cc_price)
            except:
                print("Error while checking the {} price!", .format(cc_names[i]))
                return 0

class conversions:
    def usd_to_brl(cc_usd_price):
        print("Converting the cryptocoin price!")
        try:
            brl_price = requests.get("")
            print(brl_price.status_code)
            return cc_usd_price * brl_price
        except:
            print("Error while converting the cryptocoin price!")
            return 0

#checking_coin_prices = threading.Thread(target=prices.start)

wallet.start()

1 answer

5


See lines 41 and 42:

if btc_prices >= eth_prices:
    #To do buy and sell prices!

Here you have a conditional block and does nothing within it. It is empty. Only one commenting within.

I don’t know what your intention was, but do whatever is inside. The statement pass can solve in this case.

if btc_prices >= eth_prices:
    pass 
    #HACK(código provisório!)

The pass is a word that should be used whenever the program syntactically requests a gap [...]

That quote was picked up from here.

Some questions here from Sopt I found useful and talk about the pass:

  • Thanks friend! The code worked perfectly!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.