1) Is there any way to split into ?
2)
db = [["a", "b", "c"], ["apple", "bean", "cat"]]
lines = sys.stdin.readlines()
for i in range(len(lines)):
lines = lines[:-1]
for i in range(len(lines)):
for j in range(len(db[0])):
if lines == db[0][j]:
print db[1][j]
else:
print lines
If I input:
a
b
c
abc
the output of the program will be:
apple
a
a
a
b
bean
b
b
c
c
cat
c
abc
abc
abc
abc
What I want is:
apple
bean
cat
abc
I think this problem is caused by the nested-loops. However, I do not know how to fix it.
Please help!