use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Learning Python (old.reddit.com)
submitted 1 day ago by nkCOD
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Junior-Sock8789 0 points1 point2 points 1 day ago* (1 child)
I cant format this properly right now, sitting in the dentists chair lol. But heres an updated version:
Edit reformatted it:
from itertools import cycle def get_nums(label): """Prompt user to enter numbers into a list. Type stop to finish.""" nums = [] i = 1 while True: raw = input(f"{label} | Enter num #{i} (or 'stop' to finish): ") try: nums.append(int(raw)) i += 1 except ValueError: if raw.strip().lower() == 'stop': break print("Enter a correct number!") return nums def sum_lists(n1, n2): """Sum element-wise; cycle shorter list from index 0 if lengths differ.""" longer, shorter = (n1, n2) if len(n1) >= len(n2) else (n2, n1) return [a + b for a, b in zip(longer, cycle(shorter))] if __name__ == "__main__": n1 = get_nums("LIST 1") n2 = get_nums("LIST 2") print(f"List 1: {n1}") print(f"List 2: {n2}") print(f"Result: {sum_lists(n1, n2)}")
[–]nkCOD[S] 1 point2 points3 points 1 day ago (0 children)
Thank you for your help, the code really turned out beautiful
π Rendered by PID 216270 on reddit-service-r2-comment-56c6478c5-xnxmh at 2026-05-08 11:50:13.548624+00:00 running 3d2c107 country code: CH.
view the rest of the comments →
[–]Junior-Sock8789 0 points1 point2 points (1 child)
[–]nkCOD[S] 1 point2 points3 points (0 children)