Say that the user inputs:
"daslakndlaaaaajnjndibniaaafijdnfijdnsijfnsdinifaaaaaaaaaaafnnasm"
How would you go about finding the highest number of consecutive "a" and how would you remove the "a"'s and leave only 2 of them instead of the large number of them before.
I was thinking of appending each letter into a new empty list but i'm not sure if that's correct or what to do after.
I really don't know where to begin with this one but this is what i'm thinking:
- Ask the user for input.
- Create an empty list
- Append each letter from the input into the list
What's next I have no idea.
second edit (something along these lines):
sentence = input("Enter your text: ")
new_sentance = " ".join(sentence.split())
length = len(new_sentance)
alist = []
while (length>0):
alist
print ()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…