Home > Software engineering >  How to create a sequence of variables and store them in lists while a given condition is not met?
How to create a sequence of variables and store them in lists while a given condition is not met?

Time:10-02

I'm trying to make a program that reads and executes the following conditions, how could I do that?

while condition not met: 

a1,b1,c1 = map(str, input().split())

a2,b2,c2 = map(str, input().split())

a3,b3,c3 = map(str, input().split())
...

...

...
a1, a2, a3 stored in list1[]

b1, b2, b3 stored in list2[]

c1, c2, c3 stored in list3[]

CodePudding user response:

Bad Approach

list = [][]
while condition not met:
a, b, c = map(str, input().split())
list[0].append(a)
list[1].append(b)
list[2].append(c)

a1, a2, a3 ... will be stored in list[0]

b1, b2, b3 ... will be stored in list[1]

c1, c2, c3 ... will be stored in list[2]

  • Related