[Python] Applying a function to values in dict

Discussão em 'Python' iniciado por Stack, Novembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    I want to apply a function to all values in dict and store that in a separate dict. I am just trying to see how I can play with python and want to see how I can rewrite something like this

    for i in d:
    d2 = f(d)


    to something like

    d2 = f(d) for i in d


    The first way of writing it is of course fine, but I am trying to figure how python syntax can be changed

    Continue reading...

Compartilhe esta Página