I have defined a function that generates ID. I need to increment the numbers every time I call the function.
So I used max()
function to find the last largest value stored in the list.
According to the requirements my ID should also consist of a string in front of the integers.
So I have concatenated a string with some numbers which have been stored in a list.
Now my max()
does not work,because after concatenating its converted into a alpha-numeric.Please help.I tried splitting the ID but that splits each character.
Following is the function I defined:
#!/usr/bin/python
from DB import *
def Sid():
idlist = []
for key in Accounts:
if Accounts[key]['Acctype'] == 'Savings':
idlist.append(Accounts[key]['Accno'])
if len(idlist) == 0:
return 1001
else:
abc = max(idlist)
return abc + 1
EDIT 1: Here is how I have called the function:
accno = Sid()
AppendRecord(Accno="SA"+str(accno))