Computer Science, asked by pankajkumar7812, 10 months ago

Create a list having numbers [[1,4,7,10,.....100] as its elements and then create a set from this list​

Answers

Answered by akashsinghakmsoffici
8

Answer:

mylist = [x for x in range(1,101,3)]

print(mylist{ : });

myset=set(mylist);

Explanation:i thin i dont need to explain

Answered by tiger009
1

Convert list into set

Explanation:

The following are the program in the Python Programming Language.

#define a function

def convert(lst):

 #convert and return list into set

 return set(lst)

#declare list type variable

lst=[]

#get the number of elements from the user

num=int(input("Enter the length: "))

#set the for loop that get and add elements of the list

for i in range(num):

 get=int(input())

 lst.append(get)

#call and print the function.

print(convert(lst))

The following are the description of the program.

  • Firstly, define a function and pass an argument in its parameter and then inside the function, return the converted list into the python.
  • Then, declare empty list type variable, declare a variable 'num' that get the length of the list and set the for loop that get the elements of the list from the user.
  • Finally, print and call the following function by passing a variable 'lst' in its parentheses.

Learn More:

https://brainly.in/question/16040618

Similar questions