Issue
I want to first convert strings of a list to integers and then add 1 to all elements, for example:
mylist = ["0", "1", "2"]
ints = [int(item) for item in mylist]
ints = ints+1
print(ints)
and then I want the output to be:
1, 2, 3
Not sure how I can do this, some help would be appreciated
Solution
something like this
mylist = ["0", "1", "2"]
ints = [int(item)+1 for item in mylist]
print(ints)
Answered By - eshirvana Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.