Python Forum
How to convert every even number in a list to odd?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to convert every even number in a list to odd?
#3
Hi,

In order to cope with the negative numbers,
an even shorter alternative could be to divide num by abs(num).
That gives 1 or -1 as needed.

Paul
Bruizeh likes this post
Reply


Messages In This Thread
RE: How to convert every even number in a list to odd? - by DPaul - May-01-2021, 06:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  list digit into number Voldyy 2 1,602 Jul-10-2022, 06:13 PM
Last Post: deanhystad
  Displaying list correspond to the column number danlopek14q 9 4,087 Aug-27-2021, 04:32 AM
Last Post: naughtyCat
  Get the biggest number from a two dimensional list rs74 13 4,150 Aug-09-2020, 04:02 PM
Last Post: deanhystad
  How can I print the number of unique elements in a list? AnOddGirl 5 3,345 Mar-24-2020, 05:47 AM
Last Post: AnOddGirl
  Convert a list of integers to strings? Cornelis 3 2,327 Nov-15-2019, 12:13 PM
Last Post: perfringo
  how to convert list into string Shevach 3 2,667 May-14-2019, 09:51 AM
Last Post: perfringo
  Convert string to a specific number of bytes artblinked 1 2,463 Mar-28-2019, 08:43 PM
Last Post: Larz60+
  Convert number to a different base and make calculations frequency 12 5,770 Dec-17-2018, 05:21 PM
Last Post: frequency
  Multiplying number in a list in an order pythoneer 12 6,736 Mar-23-2018, 08:21 PM
Last Post: buran
  adding a number to the list atux_null 4 3,961 Nov-06-2017, 07:01 PM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020