[Python] Python for-loop repeatedly outputting the input() for every iteration of dictionary...

Discussão em 'Python' iniciado por Stack, Setembro 24, 2024.

  1. Stack

    Stack Membro Participativo

    contact_emails = {

    'Sue Reyn' : 's.reyn@email.com',
    'Mike Filt': 'mike.filt@bmail.com',
    'Nate Arty': 'narty042@nmail.com'
    }

    new_contact = input()

    new_email = input()
    contact_emails[new_contact] = new_email

    for contact in contact_emails:
    print(new_contact + ' is ' + new_email)


    The output I want is

    s.reyn@email.com is Sue Reyn
    mike.filt@bmail.com is Mike Filt
    narty042@nmail.com is Nate Arty
    alf1@hmail.com is Alf


    the output I get it

    Alf is alf1@hmail.com
    Alf is alf1@hmail.com
    Alf is alf1@hmail.com
    Alf is alf1@hmail.com


    What am I doing wrong? How should I fix this code to make it output what I would like it to output?

    Continue reading...

Compartilhe esta Página