I want to accept the input as lists. Is there a way like int(input())
to do this?
I want to accept the input in []
:
Enter list1: [80, 60, 70]
Is it possible to do this without using strip()
or split()
?
I want to accept the input as lists. Is there a way like int(input())
to do this?
I want to accept the input in []
:
Enter list1: [80, 60, 70]
Is it possible to do this without using strip()
or split()
?
split is probably the best way in most cases but it's not the only way.
exec("list = "+input())
would be another and would expect a list formatted like you said.
why not split? are you struggling to format the input? you could conditionally slice off the first and last characters or use regex to remove all non numerical characters.