Home > other >  Beg big help!!!!!!
Beg big help!!!!!!

Time:09-15

In python exclusive or ask the following questions:

If I have a set of Numbers, a digital have arisen only once, other appear twice, that how to find the appear a number?

CodePudding user response:

For example, unclear meaning

CodePudding user response:

 s=,1,6,2,2,3,3,4,4,5,5 [1] 
Dict1={}
For x in s:
If dict1. Get (x, 'FFFF)==' FFFF ':
Dict1 [x]=1
The else:
Dict1 [x] +=1
Print (dict1)
Print (list ([x, dict1 [x]] for x in dict1. Keys () if dict1 [x]==1))

CodePudding user response:

 
S=,1,6,2,2,3,3,4,4,5,5,7 [1]
Dict1={}
For x in s:
If dict1. Get (x, 'FFFF)==' FFFF ':
Dict1 [x]=1
The else:
Dict1 [x] +=1
Print (dict1)
Print (list ([x, dict1 [x]] for x in dict1. Keys () if dict1 [x]==1))

Dict1={}
For x in s:
Dict1 [x]=dict1. Setdefault (x, 0) + 1
Print (dict1)
Print (list ([x, dict1 [x]] for x in dict1. Keys () if dict1 [x]==1))

CodePudding user response:

Is this meaning?

 
LST=(1, 1, 6, 2, 2, 3, 3, 4, 4, 5, 5, 7]
Once_num=filter (lambda x: LST. The count (x)==1, LST)
Print (list (once_num))
  • Related