Based on your update on what bid_data
contains:
Do:
int(bid_data[6].split(':')[1].strip()) # returns an integer
Explanation:
The Python string method strip()
removes excess whitespace from both ends of a string (without arguments)
Original below:
Below is based on using the input you gave, ['Quantity Required', ' 1']
, to get the output of 1
If the input is ['Quantity Required', ' 1']
as a list:
>>> my_input = ['Quantity Required', ' 1']
>>> int(my_input[1].strip())
>>> 1 # is an integer
Where you can replace my_input
with the literal list.
If the input is a string:
>>> string = "['Quantity Required', ' 1']"
>>> int(string.split(', ')[1].strip("'] "))
>>> 1 # is an integer
8
solved how to remove [ , ] and single quote in class list in python 3 in single line of code? [closed]