对于下面的代码:分离列表分为两个 - Python的
print("Welcome to the Atomic Weight Calculator.")
compound = input("Enter compund: ")
compound = H5NO3
lCompound = list(compound)
我想从列表lCompund
创建两个列表。我想要一个字符列表和另一个数字列表。所以我可能看起来像这样:
n = ['5' , '3']
c = ['H' , 'N' , 'O']
有人可以请帮助提供一个简单的解决方案吗?
您是否知道这些名单并不H5NO3和HN5O3之间(比方说)区分?您可能想要为氮保存1(即N = ['5','1','3'])以获得唯一的映射。 – starsplusplus