How to input a list of tuples
Question: I am coding a python program related to graphs.  
My main is like this

    
    
    if __name__=='__main__': 
    cns = [(0,1), (0,2),(1,2), (1,3),(3,1)]
    G=make_graph(cns)
    r=DFS(G)
    

I want to change the program such that the user can input the data.

    
    
    cns = [(0,1), (0,2),(1,2), (1,3),(3,1)]
    

this list is to be read from the user. How to input a list of tuples, how to
do that?

Can I use `raw_input` for this purpose?


Answer: 
    from ast import literal_eval
    
    cns = literal_eval(raw_input("Please enter the data: "))
    

