May-23-2018, 03:57 PM
May-23-2018, 04:21 PM
s = "ball" r = "" for item in s: # iterate over chars in s, i.e. value of item will change with each iteration of the loop print('item value -> {}'.format(item)) r = item.upper() + r # value of r will change, adding the value of item, upper case at the beginning of the old r value print('r value -> {}'.format(r)) print(r) # print the new value of rI have added 2 print statements to show item and r values at each iteration.