Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to python! Loops
#2
There are several options, one of them presented below (unpack, calculate, output):

spam = [[5, 6, 7], [50, 60, 70]]
for item in spam:
    first, second, third = item
    print(f'{first}: {second * third}')
Output of this code will be:

Output:
5: 42 50: 4200
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
New to python! Loops - by Seeley307 - May-12-2020, 12:46 AM
RE: New to python! Loops - by perfringo - May-12-2020, 05:00 AM
RE: New to python! Loops - by jefsummers - May-13-2020, 04:17 PM
RE: New to python! Loops - by ibreeden - May-15-2020, 02:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error in loops, new to Python jhall710 20 12,553 Apr-25-2017, 05:18 AM
Last Post: smbx33

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020