I've got a list name users, and I want a second list named account_no to take only the first part of the contents of users.
users = [
'GB1520*Adam Johnson*07293105657',
'ZA5584*Dean Davids*07945671883'
]
account_no = []
def find_accountno():
for index in range(len(users)):
# I want to take the first 6 characters of users[index]
acc = users[index: 6]
account_no.append(acc)
print(users)
find_accountno()
print(account_no)
And this is the desired output:
['GB1520', 'ZA5584']
But, instead, I'm getting this:
[['GB1520*Adam Johnson*07293105657', 'ZA5584*Dean Davids*07945671883'], ['ZA5584*Dean Davids*07945671883']]