Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8728813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:43:10+00:00 2026-06-13T08:43:10+00:00

I have have two list and and I am trying to compare differences in

  • 0

I have have two list and and I am trying to compare differences in $ amount over a certain amount.

the list are

file1 = ['file1,product1,-1000.56', 'file1,product2,500.43']

file2 = ['file2,product1,-1001.37', 'file2,product2,511.99']

I want to print the differences if over $5 in the below format

file1 product2 500.43
file2 product2 511.99

Difference = $11.56

Product 1 won’t display because it’s less than $5

Is there a good way to do this?

I have tried…

for i in file1:
    i.split(",")

This works to get the list split out but how to I compare the two $ amounts, and display only $5 or more.

If someone could give me a way to compare the two $ amounts over $5 difference I can prob figure out the rest.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:43:11+00:00Added an answer on June 13, 2026 at 8:43 am

    use zip() to traverse over both lists:

    In [114]: file1 = ['file1,product1,-1000.56', 'file1,product2,500.43']
    
    In [115]: file2 = ['file2,product1,-1001.37', 'file2,product2,511.99']
    
    In [116]: for f1,f2 in zip(file1,file2):
        spl1=f1.split(',')     #returns something like ['file1', 'product2', '500.43']
        spl2=f2.split(',')     #returns something like ['file2', 'product2', '511.99']
    
        diff=abs(float(spl1[-1])-float(spl2[-1]))  ##use abs() to find the difference
    
        if diff>5:  
            print " ".join(spl1)                    #use print() as you're on py 3.x 
            print " ".join(spl2)                    #join the lists by " " 
            print "${0}".format(diff)
       .....:         
       .....:         
    file1 product2 500.43
    file2 product2 511.99
    $11.56
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a list view containing two childs. Now i am trying to
I am trying to build JSON from two fields. Say, I have a list
i'm trying to create a multilevel list. I have two tables 'State' and 'City'.
I am trying to merge two list in parallel. I have two sorted lists
I have two tables containing product information, and product variations. I’m trying to list
I'm trying to compare two arrays in groovy. My attempts so far have yielded
I have two lists that I am trying to compare with < or >
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
I have two List s of type int where I store point coordinates called
I have two list: list_a = [<User: x>, <User: y>] list_b = [False, True]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.