Method # 1: The Naive Method
This is the most common method that amazes any programmer when doing this kind of operation. Just looping through the entire list and converting each line of the list to int by casting.
Original list is: [`1`,` 4`, `3`,` 6`, `7`] Modified list is: [1, 4, 3, 6 , 7]
Method # 2: Using List Comprehension
This is just a kind of copy of the above method, implemented using a list comprehension, a kind of shorthand which the developer is always looking for. This saves time and complexity of coding the solution.
Original list is: [`1`,` 4`, `3`,` 6`, `7`] Modified list is : [1, 4, 3, 6, 7]
Method # 3: Using
This is the most elegant, pythonic and recommended method for this specific task. This function is intended solely for this kind of task and should be used to accomplish them.