如何降低索引列表?用此代码和变量列表我该如何洗牌变量列表的索引?
#turns string to list
list=[]
#gets the sentence to count and what to count and deletes punctuation
punctuations = '''!()-[]{};:'"\,<>./[email protected]#$%^&*_~'''
sentence=input("Enter sentence to count: ")
sentence=sentence.lower()
no_punct = ""
for char in sentence:
if char not in punctuations:
no_punct = no_punct + char
list=no_punct.split()
#this shows whether it is there or not
index=[index+1 for index,list in enumerate(list)]
print("the indices are ",index)
它不是一个重复的,因为这没有工作,但谢谢 –