Python Forum
Output difference from 2 lists of different sizes with words
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Output difference from 2 lists of different sizes with words
#1
Hi everyone.

Let say I have the following 2 lists with words of different sizes for example,
list0=['guava','apple','banana','strawberry','orange']
list1=['orange','pineapple','apple']
difference=list(set(list0).symmetric_difference(list1))
print(difference)
Output:
['banana', 'guava', 'strawberry', 'pineapple']
Output above is the mix of words that are not present in both sets that I am only able to do at this stage.

However, I'd like to seek your help on how can I achieve the the following desired output please? Huh
Output:
Words appear in first list and not second list = guava, banana, strawberry Words appear in second list and not first list = pineapple
Thanks a lot and have a great weekend
Reply


Messages In This Thread
Output difference from 2 lists of different sizes with words - by gracenz - Sep-02-2022, 02:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to create a table with different sizes of columns in MS word pepe 8 1,834 Dec-08-2023, 07:31 PM
Last Post: Pedroski55
  Printing effect sizes for variables in an anova eyavuz21 2 1,057 Feb-01-2023, 02:12 PM
Last Post: eyavuz21
  Generate a string of words for multiple lists of words in txt files in order. AnicraftPlayz 2 2,908 Aug-11-2021, 03:45 PM
Last Post: jamesaarr
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,505 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  Difference in list output OokaydO 6 3,463 Nov-09-2019, 12:33 AM
Last Post: OokaydO
  converting data sizes like: 4k, 32k, 4m, 16m, 1g, etc Skaperen 1 2,245 Jul-16-2019, 01:37 AM
Last Post: Skaperen
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,389 Mar-20-2019, 08:01 PM
Last Post: stillsen
  How to format text to modify itself for different console sizes. FWendeburg 0 1,629 Feb-18-2019, 06:43 PM
Last Post: FWendeburg
  Compare all words in input() to all words in file Trianne 1 2,821 Oct-05-2018, 06:27 PM
Last Post: ichabod801
  Convert file sizes: will this produce accurate results? RickyWilson 2 8,234 Dec-04-2017, 03:36 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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