How would i use a function to grab specific parts of a string?
Say for instance my string consisted of data such as the following:
'12345678 123456.78 Doe, John D.' # Data that could be representative of bank software#
How do i tell python to make the first chars of the string an int, the second part of the string to be a float and the last part should automatically remain a string right?
for line in file_obj:
print(line) #would yield something like this '12345678 123456.78 Doe, John D.'
If i had functions like:
def find_balance():
return float
def find_acc_num():
return int
def find_name():
return str
What would my parameters be? Would for iteration be the best way to solve the problem? I want to be able to change account information (balances and names) as long as the user can supply the correct account number. I am new to using functions and am a bit unsure how to go about doing this...
Thanks in advance for any help i really appreciate it. =D