Skip to content

Instantly share code, notes, and snippets.

@ALXTorresC
Created January 17, 2018 00:01
Show Gist options
  • Save ALXTorresC/3fe0c4d3867c17909db510b80d7e7e33 to your computer and use it in GitHub Desktop.
Save ALXTorresC/3fe0c4d3867c17909db510b80d7e7e33 to your computer and use it in GitHub Desktop.
Ejercicio003
#-*- coding: utf-8 -*-
a = [1,2,3,4,3,2,1,2,3,4,5,6,7,9,8,7,6,7,8]
def contador(a, x):
b = []
for i in a:
if i <= x:
b.append(i)
return b
if __name__ == '__main__':
x = int(input("Ingrese número a comparar: "))
print(contador(a,x))
@ALXTorresC
Copy link
Author

It's not so much dificult to follow this code, the contador function takes the a list and a number typed by user, compares each item of the list a with the user's number and all values fewer than user's number are moved to b list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment