如何降低索引列表?用此代碼和變量列表我該如何洗牌變量列表的索引?
#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)
它不是一個重複的,因爲這沒有工作,但謝謝 –