+ 1
Find the element that appears once in a array
Can you please help me to sole above problem in python3
8 Antworten
0
well...atleast you've had a go, this is how I would do it:-
mylist = [1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6]
print(*[x for x in mylist if mylist.count(x) == 1], sep=', ')
+ 3
What did u already try?
I see no code
+ 2
Hurry up yourself. We also help doing homework if your part is big enough.
+ 1
Use list comprehension and lists' "count" method.
+ 1
rodwynnejones ....pleaaaaase discipline
0
I didn't
0
def bubblesort(arr):
n=len(arr)
for i in range(n):
if arr[0] != arr[1] and arr[0] != arr[2]and arr[0] != arr[3]and arr[0] != arr[4]and arr[0] != arr[5]and arr[0] != arr[6]and arr[0] != arr[7]and arr[0] != arr[8]and arr[0] != arr[9]and arr[0] != arr[10]and arr[0] != arr[11]and arr[0] != arr[12]and arr[0] != arr[13]and arr[0] != arr[14]and arr[0] != arr[15]and arr[0] != arr[16]and arr[0] != arr[13]and arr[0] != arr[18]and arr[0] != arr[19]:
print(arr[0])
arr = [-20, 20, -10, 20, 0, 4, 8, -20, 10, -10, 8, 6, 15, 9, 18, 35, 40, -30, -90, 99]
bubblesort(arr)
here i try one comparison of arr[0] .how can i compare every element of array with other element using for loop
i.e.
Find the elements from an array A, that appears only once.
E.g.
N = 20
A = {-20, 20, -10, 20, 0, 4, 8, -20, 10, -10, 8, 6, 15, 9, 18, 35, 40, -30, -90, 99}
Array elements which appeared only once are (order of element should not change).
= { 0, 4, 10, 6, 15, 9, 18, 35, 40, -30, -90, 99 }
0
thanks buddy