This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
DSA/count_in_array.py

15 lines
257 B
Python
Raw Normal View History

2019-02-20 12:58:39 +00:00
#!/usr/bin/env python3
def count_in_array(x, A):
c = 0
for elem in A:
if elem == x:
c = c + 1
return c
def main():
print(count_in_array(5, [7, 5, 16, 3, 10, 5, 8, 1, 29, 13, 28]))
if __name__ == "__main__":
main()