-4

How do I create a two dimensional list so that when I input two values a, b (separeted by a comma) until I enter a empty row so that the list looks like this [[a, b], [c, d], [e, f]] with float values?

Edit: My desired input would be for example:

print(input x,y)

2.0,-1.0
3.0,8.0
-1.0,4.0
(empty row)

And then my desired output would be:

[[2.0, -1.0], [3.0, 8.0], [-1.0, 4.0]

And if the first input is an empty space it would print "No input"

monkey D
  • 1
  • 3
  • What do you ask precisely? What is your desired input and output? Maybe update your post with that. – Chris Fowl Oct 26 '18 at 13:18
  • Your question is not quite clear. If you give us an example, showing us the input and the desired output, that would help. You also should show us some of your own work on this problem, preferably including a code attempt. – Rory Daulton Oct 26 '18 at 13:19

1 Answers1

2

You can use a list comprehension like this:

[[float(f) for f in l.split(',')] for l in iter(input, '')]
blhsing
  • 91,368
  • 6
  • 71
  • 106