I was wondering if there is any way to assign 2 values (G and H) to say a list of ["egg", "chicken"] in Pyth. In python it would be something along the lines of

G, H = ["egg", "chicken"]

At the moment the shortest way I can think of would be something like


which uses the lookup function to index the list and store each one individually. I tried doing something like

=(G H)["egg""chicken")

but when I look at the debug info Pyth debug info it doesn't seem to be what im after. Any help would be good thanks. This may include shortening the original solution or giving me an explanation on how to do the tuple assignment

  • 2
    \$\begingroup\$ I'm not entirely sure this is on topic for this site. This is asking for help using a language, rather than for golfing tips. Granted that language is a golfing language, but I still think this is more appropriate for Stack Overflow \$\endgroup\$ Commented Sep 9, 2021 at 22:37
  • \$\begingroup\$ Are you looking for built-in or nice ways to do this, or short code that produces the assignment by any means? \$\endgroup\$
    – xnor
    Commented Sep 9, 2021 at 22:50
  • \$\begingroup\$ both would be nice \$\endgroup\$
    – scpchicken
    Commented Sep 9, 2021 at 22:55
  • 4
    \$\begingroup\$ @cairdcoinheringaahing I agree with you, but I think this question should be modified to better suit CGCC instead of being moved to SO, since the OP does seem to want help with shortening their code. \$\endgroup\$
    – user
    Commented Sep 10, 2021 at 0:01

1 Answer 1


This is exactly what the A builtin does: “Assign the first value of the list to G and the second to H. Return the input.”

  • \$\begingroup\$ wow thanks exactly what i was looking for \$\endgroup\$
    – scpchicken
    Commented Sep 9, 2021 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.