Home > database >  Python for help
Python for help

Time:10-16

Topic: put an element for all Numbers in the list of all the even add 1

CodePudding user response:

Very simple,
Traverse the list, if the element is even, the element to add 1, other unchanged,

CodePudding user response:

 a=[6] 
A=[e + 1 if e % 2==0 else e for e in a]
Print (a)
  • Related