dimitri.golubev1978
BAN USER
Comments (4)
Reputation -10
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
-1
of 1 vote
Python 2.7.x code:
with open('index.txt', 'r') as f:
l = f.readlines()
l = [i.replace('\n', '') for i in l]
print l[0]
print l[len(l)-1]
Comment hidden because of low score. Click to expand.
0
of 0 vote
Python 2 rulez
def removeDuplicates(lst):
return len(set(lst))
Comment hidden because of low score. Click to expand.
-1
of 1 vote
Python 2...
# Lists of integers:
a = [1,2,4,5,8,9]
b = [3, 4, 5, 9]
union = sorted(list(set(a).union(set(b)))) # ==> [1, 2, 3, 4, 5, 8, 9]
intersection = sorted(list(set(a).intersection(set(b)))) # ==> [4,5,9]
# If you want to print it out:
for i in union:
print i
# or
import sys
for i in l:
sys.stdout.write(str(i) + ' ')
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Python 2.7.x code:
- dimitri.golubev1978 November 05, 2015def movezeros(arr):
n = arr.count(0)
for i in xrange(n):
arr.remove(0)
arr.append(0)
return arr