Skip to content

[Felix] Lab functions done#13

Open
imfap1 wants to merge 2 commits intoIronhack-data-bcn-oct-2023:mainfrom
Ironhack-Bootcamp:main
Open

[Felix] Lab functions done#13
imfap1 wants to merge 2 commits intoIronhack-data-bcn-oct-2023:mainfrom
Ironhack-Bootcamp:main

Conversation

@imfap1
Copy link
Copy Markdown

@imfap1 imfap1 commented Oct 12, 2023

image

@bripollc
Copy link
Copy Markdown

Felix:)

Olé!!! Buen trabajo! Muy muy buen lab, la verdad! Las funciones te ahorrarán tiempo y simplificación de código así que me alegro de que se te den bien ✨✨

Te dejo algunas manera de resolver el bonus:

  • Write a function that returns the mode of a list, i.e.: the element that appears the most times.
def mode_counter(arr):
    counter = {} 

    for i in arr:
        if i in counter:
            counter[i] += 1  
        else:
            counter[i] = 1

    mode = max(counter, key=counter.get)

    return mode
  • 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)

FELICIDADES 🙌🏼

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