Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edu functions #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

edwardrodgermartinez
Copy link

No description provided.

@bripollc
Copy link

Edu:)

Muy muy buen trabajo! Felicidades. 🌻 Todo está perfecto!!!!!!! Me alegro de que se te den bien las funciones, te ahorrarán mucho tiempo y simplificación de código. Solo un pequeño tip:) Después de tu función, con que tan solo declares test(nombre de la función) es suficiente (no hace falta que vuelvas a copiar la función entera en la celda:))

Te dejo el bonus por aquí!

  • Write a function that returns the mode of a list, i.e.: the element that appears the most times.
def mode_counter(arr):
    frequency_count = {}
    for i in arr:
        if i in frequency_count:
            frequency_count[i] +=1
        else:
            frequency_count[i] = 1
    
    highest_count = 0
    
    for item, count in frequency_count.items():
        if count > highest_count:
            highest_count = count
            mode = item
    solution = mode
    return solution

Casi lo tenías!!!!!!! El único problema es la línea solution = item. Debería ser solution = mode jeje. Así te pasa el test 🙃

  • Write a function that receives a string of comma separated words and returns a string of comma separated words sorted alphabetically.
def sort_alpha(string):
    word_list = string.split(", ") 
    word_list.sort()  
    sorted_string = ", ".join(word_list)
    return sorted_string
a_string = "call, you, later"
sort_alpha(a_string)

Te dejo una manera para hacerlo:)

Hasta mañana!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants