Ok my program looks like this:

U = set([0,1,2,3,4,5,6,7,8,9])
A = set([2,4,5])
B = set([5,8])
C = set([5])

def main():
    print('This is a program to give complement to given elements')
    x = input('Enter elements bla bla: ')
    y = U.difference(x)
    print('The complement of given elements are:', y)

main()

As you might have guessed, if I input e.g. 'A'. I input the string A, not the list [2,4,5] My question is:
How do I make a input where I can input A as a list and not as a string?

Ps. Sorry for any incorrect english

You can enter a python list and then convert it using eval

userInput = input("Enter a python list: ")
mylist = eval(userInput.strip())

# check that it's a list
assert(isinstance(mylist, list))
print(mylist)

""" running the program in a shell:
$ python3 myinput.py
Enter a python list: [3, 4, 5]
[3, 4, 5]
"""

Perfect. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.