What is the easiest or most elegant way to let the user input a list in a console program?
Jump to Post
A list with the brackets and commas?
The easiest way is also taboo:
>>> eval(raw_input("Enter a list: ")) Enter a list: [1,2,3] [1, 2, 3]
IMO, eval() should almost never be used for the simple reason that it allows the user to type ANYTHING. As in…
All 3 RepliesReply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.