Home > other >  Inquire how to save the result of the num in a list?
Inquire how to save the result of the num in a list?

Time:11-13

Inquire how to save the result of the num in a list? If the num is digital type string?
 
For num in range (2100 1) :
Prime=True
For I in range (2, num) :
If num % I==0:
Prime=False
Break
If prime:
Print (num)

CodePudding user response:

Directly append line
 
NewList=[]
For num in range (2100 1) :
Prime=True
For I in range (2, num) :
If num % I==0:
Prime=False
Break
If prime:
NewList. Append (num)
Print (newList)

CodePudding user response:

, put Numbers in the list of character type is OK,
Upstairs code no problem
  • Related