Python Forum
[split] Homework help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Homework help
#1
Hi Buran

I am having a similar issue to the above.
The below is my code, but my dictionary isn't including the word which has punctuation in at all, I attempted to follow your advice but no success, any more hints?

def myfunction(cadena):
    
    texto=cadena
    x=texto.lower().split()
    Dict={}
    
    for element in x:
        if element.isalpha():
                if element in Dict:
                    Dict[element]+=1
                else:
                    Dict[element]=1
        else:
            element[:-1] 
    return(Dict)
    

print(myfunction("Hola que haces? Por favor respondeme, di hola por lo menos!"))
Reply


Messages In This Thread
[split] Homework help - by JayBand - Sep-25-2019, 08:49 PM
RE: [split] Homework help - by perfringo - Sep-26-2019, 05:06 AM
RE: [split] Homework help - by buran - Sep-26-2019, 06:48 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020