count=0
x='yes'
name=['thilini','umanda','dilki']
result=[20,40,22]
dct=dict((a,b)for a,b in zip(name,result))
golf_no=int(input('how many golfers are there in the group?'))
while golf_no>count:
count=count+1
print('enter the name and the result')
name_new=str(input('enter the name'))
result_new=int(input('enter the result'))
if name_new in name:
print('this name is already exists')
answer=str(input('are you sure that you want to replace?'))
if answer==x:
print('data is altered')
else:
print('try again')
else:
name.append(name_new)
result.append(result_new)
print('your data entry was successful')
print(name)
print(result)
答案 0 :(得分:0)
您可以通过索引方法找到名称的索引。然后替换该索引的结果值。如果您需要任何帮助,请告诉我。