Anthony Irwin wrote: > walterbyrd wrote: >> The strings start with whitespace, and have a '*' or an alphanumeric >> character. I need to know how many whitespace characters exist at the >> beginning of the string. >> > > Hi, > > I am new to python and just really learning but this is what I came up > with. > > #!/usr/bin/env python > > def main(): > s = " abc def ghi" > count = 0 > > for i in s: > if i == ' ': > count += 1 > else: > break > > print count > > if __name__ == '__main__': > main() >
Ahh even better would be to use some of the python library functions that I am still finding more about. s = " abc def ghi" print (len(s) - len(s.lstrip())) I am really starting to like python the more I use it. -- Kind Regards, Anthony Irwin http://www.irwinresources.com http://www.makehomebusiness.com email: anthony at above domains, - www. -- http://mail.python.org/mailman/listinfo/python-list