69.1k views
0 votes
Help me pls with python

Write a program that prompts the user to enter a sentence



Create a list to store each unique letter in the sentence

Create a second list that stores the number of times each letter appears in the sentence



Print out the letter frequency of each letter



Eg

>Enter a sentence: abracadabra



The letter a appears 5 times

The letter b appears 2 times

The letter r appears 2 times

The letter c appears once

The letter d appears once
I got this so far...

Help me pls with python Write a program that prompts the user to enter a sentence-example-1
User Srikanth P
by
5.1k points

1 Answer

1 vote

Answer:

sen = input("Enter a sentence: ")

sen = sen.lower()

sen = sen.replace(" ","")

sen = list(sen)

sen.sort()

print(sen)

sen1 = []

for i in sen:

if i not in sen1:

sen1.append(i)

print(sen1)

sen2 = []

for i in sen1:

sen2.append(sen.count(i))

print(sen2)

for i in range(len(sen1)):

print("The letter",sen1[i],"appears",sen2[i],"times")

User Ulrich Dangel
by
5.4k points