Answers for "change to list in python"

2

change item in list python

#To change elements in list base on a specific condition 
#Using list comprehension
original_list = [1,20,3,40,5]
new_list = ['Do something' if x > 10 else x for x in original_list]

# [1, 'Do something', 3, 'Do something', 5]
Posted by: Guest on August-23-2021
7

how to convert a set to a list in python

my_set = set([1,2,3,4])
my_list = list(my_set)
print my_list
>> [1, 2, 3, 4]
Posted by: Guest on May-19-2020

Code answers related to "change to list in python"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language