Skip to content

Instantly share code, notes, and snippets.

@makesomelayouts
Created February 11, 2023 19:19
Show Gist options
  • Select an option

  • Save makesomelayouts/bb3070f320d432b650f3e1c0fd95c8b1 to your computer and use it in GitHub Desktop.

Select an option

Save makesomelayouts/bb3070f320d432b650f3e1c0fd95c8b1 to your computer and use it in GitHub Desktop.
# Converting a list of strings to a list of integers
numbers = ['1', '2', '3', '4', '5']
result = list(map(int, numbers))
print(result) # [1, 2, 3, 4, 5]
# Multiplying each element of a list by 2
numbers = [1, 2, 3, 4, 5]
result = list(map(lambda x: x*2, numbers))
print(result) # [2, 4, 6, 8, 10]
# Converting a list of string representations of numbers to a list of floats
numbers = ['1.1', '2.2', '3.3', '4.4', '5.5']
result = list(map(float, numbers))
print(result) # [1.1, 2.2, 3.3, 4.4, 5.5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment