the code works in my pc but check50 find this error and I don't understand why: Traceback (most recent call last): File "/tmp/tmptndsrole/test_two_coins/testing.py", line 28, in bitcoin.main() TypeError: main() missing 1 required positional argument: 'n'

import sys import requests

def main(n): price_in_usd = get_bitcoin_price() amount = n*price_in_usd


def get_bitcoin_price(): try: #make request response = requests.get("https://api.coindesk.com/v1/bpi/currentprice.json") #format in json data_json = response.json() #get the price index of btc prices = data_json["bpi"] #find the price in usd price_in_usd = prices["USD"]["rate_float"] return price_in_usd except requests.RequestException: print("Problem with request")

if name == "main": try: n = int(sys.argv[1]) main(n) except ValueError: print("Command-line argument is not a number") sys.exit(1) except IndexError: print("Missing command-line argument") sys.exit(1)

  • 1
    It looks like check50 does not expect main to take an argument. It would be very helpful to the reader if the code was formatted properly. Edit the question; select the code; press the {} icon in the format bar to format the code. Commented Sep 22, 2023 at 0:54
  • For one thing, the line that detects "name" is "main" should have double underscores, like this: if __name__ == "__main__":
    – kcw78
    Commented Sep 26, 2023 at 14:45


You must log in to answer this question.

Browse other questions tagged .