Python Forum
Supposed to print out even numbers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Supposed to print out even numbers
#3
The reason for this is that your code is checking to see if num is even, when you really want to be checking list1[num]:

    # checking condition
    if list1[num] % 2 == 0:
        print(list1[num], end=" ")
Reply


Messages In This Thread
Supposed to print out even numbers - by DallasPCMan - May-21-2020, 02:59 PM
RE: Supposed to print out even numbers - by Yoriz - May-21-2020, 03:23 PM
RE: Supposed to print out even numbers - by GOTO10 - May-21-2020, 03:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python class doesn't invoke setter during __init__, not sure if's not supposed to? mtldvl 2 3,353 Dec-30-2021, 04:01 PM
Last Post: mtldvl
  Print max numbers in a list jimmoriarty 1 2,171 Sep-25-2020, 07:29 AM
Last Post: DPaul
  Is there a way i print odd and even numbers separately? spalisetty06 5 2,747 Jul-21-2020, 06:48 PM
Last Post: spalisetty06
  first k non prime numbers print bsrohith 7 7,552 Jun-20-2019, 10:48 AM
Last Post: arycloud
  my function is stuck on loop - even when it not supposed to be korenron 2 2,373 May-26-2019, 12:31 PM
Last Post: korenron
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,757 May-09-2019, 12:19 PM
Last Post: Pleiades
  Why can't I print numbers in Python? skrivver99 2 2,792 Nov-04-2018, 09:47 PM
Last Post: snippsat
  How to test a function that is supposed to return NoneType? w0mb4rt 1 3,496 Feb-17-2018, 07:38 PM
Last Post: Gribouillis
  Print list from splitted range of numbers prashant8530 1 2,814 Sep-04-2017, 08:03 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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