Skip to content

Edu functions#8

Open
edwardrodgermartinez wants to merge 1 commit intoIronhack-data-bcn-oct-2023:mainfrom
edwardrodgermartinez:main
Open

Edu functions#8
edwardrodgermartinez wants to merge 1 commit intoIronhack-data-bcn-oct-2023:mainfrom
edwardrodgermartinez:main

Conversation

@edwardrodgermartinez
Copy link
Copy Markdown

No description provided.

@bripollc
Copy link
Copy Markdown

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