Home > database >  Which bosses to help me, just contact with Python
Which bosses to help me, just contact with Python

Time:09-17

How to use the Python language, using a while loop to print out your student id contains an odd number? (if the student id is: 52894016)

CodePudding user response:

Number="52894016"
Xuehao=list (number)
I=0
While iIf the int (xuehao [I]) % 2==1:
Print (xuehao [I])
I +=1

CodePudding user response:

 
Number="52894016"
For I in number:
If the int (I)/2!=0:
Print (int (I))

CodePudding user response:

refer to the second floor MuSa xiaoxiang reply:
 
Number="52894016"
For I in number:
If the int (I)/2!=0:
Print (int (I))


Should be the if the int (I) % 2!=0:

CodePudding user response:

reference weixin_46538011 reply: 3/f
Quote: refer to the second floor MuSa xiaoxiang reply:
 
Number="52894016"
For I in number:
If the int (I)/2!=0:
Print (int (I))


Should be the if the int (I) % 2!=0:

Deliberately leave a bug for you, ha ha
  • Related