Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use if with and function?
#1
Hi members, i am new here and I have so many requests in phyton to learn... Please help me... i write a code like this but not working

num = input("Please enter a number: ")

if num.isalpha():
    print(f"{num} is not a number.")

elif type(num) == int and (num %2) == 0:    #If the value entered is a number and divided by two,
    print(f"{num} çift sayıdır")            #say it as an even number

else:
    print(f"{num} is an odd number")
why this code not working...
if i enter 4 , it says is an odd number... (this is false)
if i enter 5, it says is an odd number...
if i enter a, it says is not a number...

how do i fix it?
Reply


Messages In This Thread
Use if with and function? - by ibutun - May-30-2020, 05:42 PM
RE: Use if with and function? - by ndc85430 - May-30-2020, 05:48 PM
RE: Use if with and function? - by ibutun - May-30-2020, 05:55 PM
RE: Use if with and function? - by menator01 - May-30-2020, 05:56 PM
RE: Use if with and function? - by ibutun - May-30-2020, 06:35 PM
RE: Use if with and function? - by pyzyx3qwerty - May-30-2020, 05:57 PM

Forum Jump:

User Panel Messages

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