Created
January 17, 2018 00:01
-
-
Save ALXTorresC/3fe0c4d3867c17909db510b80d7e7e33 to your computer and use it in GitHub Desktop.
Ejercicio003
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- 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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.