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)
CodePudding user response:
Very simple,CodePudding user response:
a=[6]
A=[e + 1 if e % 2==0 else e for e in a]
Print (a)