'Convert the second element in a nested array from a string into an int

I was wondering if someone could help me convert a nested element that is originally a string into an int in python without the use of pandas.

x=[('cat', '2'),('dog','3')]

to

x=[('cat', 2),('dog',3)]

I have tried to do as per below; however, it only works for a regular list without words.

r = list(map(int, x))


Solution 1:[1]

I have this solution

x=[('cat', '2'),('dog','3')]
r=[(a, int(b)) for (a, b) in x]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peterrabbit