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

Question:

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’

Asked By: Pren Ven

||

Answers:

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'])
Answered By: tetris programming
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.