Skip to content

Instantly share code, notes, and snippets.

  • Save naemazam/1cbc6059678e8b3135ad70613b948206 to your computer and use it in GitHub Desktop.
Save naemazam/1cbc6059678e8b3135ad70613b948206 to your computer and use it in GitHub Desktop.
Enter a positive integer n between 1 and 100, and randomly generate a positive integer m not greater than n with n as the random number seed. Generate a list ls containing elements 1, 2, 3... n, delete the elements with the integer multiple of m in the list ls, and output the original list and the list after deleting the multiple of m in two lines.
import random
n=int(input("Enter n value: "))
random.seed(n)
m=random.randint(1,n)
print(m)
lis=[i for i in range(1,n+1)]
print(lis)
up_lis=[i for i in lis if i%m!=0]
print(up_lis)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment