1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Swapping a List

Discussão em 'Python' iniciado por Stack, Abril 11, 2025.

  1. Stack

    Stack Membro Participativo

    I'm stuck on this one because I've never used swap before. I've tried a few different ways but keep getting an error that swap is not defined.

    Write a function swap that swaps the first and last elements of a list argument.

    Sample output with input: 'all,good,things,must,end,here' ['here', 'good', 'things', 'must', 'end', 'all']

    values_list = input().split(',') # Program receives comma-separated values like 5,4,12,19
    swap(values_list)

    print(values_list)

    Continue reading...

Compartilhe esta Página