Home > Back-end >  TypeError: int() argument must be a string, a bytes-like object or a number, not 'set'
TypeError: int() argument must be a string, a bytes-like object or a number, not 'set'

Time:01-22

api_key = '2323'
n_page = '1'

params = {
         'api_key': {api_key},
         'start_page' : {n_page},
}

params['start_page'] = str(int(params['start_page'])   10)

I get this error considering in the last line:

TypeError: int() argument must be a string, a bytes-like object or a number, not 'set'

CodePudding user response:

You have a set inside your dictionary:

params['start_page'] -> {"1"}

What you want to have is the following:

api_key = '2323'
n_page = '1'

params = {
    'api_key': api_key,
    'start_page': n_page,
}

params['start_page'] = str(int(params['start_page'])   10)
print(params['start_page'])
  • Related