I'm trying to write a program that has a function that takes in a string and prints the number of capital letters in the first line, then prints the sum of their indices in the second line.
Here is what I came up with but I am getting errors. Anybody knows what I can fix on this code to make it run?
import sys
def string(s):
a={"UPPER":0}
for b in s:
if b.isupper():
a["UPPER"]+=1
print ("No. of Upper case characters : ", a["UPPER"])
ind = [idx for idx in range(len(val)) if val[idx].isupper()]
Sum=sum(ind)
print(Sum)
val = input("")
string(sys.argv[1])