Hey fellow Daniweebs,
I would like to present a code to you, which seems to be not working for some reason , kindly help me

name = input("Enter your name:  ")
age = input("Enter your age:  ")

if type(name) != str or type(age) != int:
    print("PLEASE ENTER VALID CREDNTIALS", end ="!!!")

    print("Congrats", name , "!, You are registered")

the output always seems to come out to be " PLEASE ENTER VALID CREDNTIALS!!!" even if i input string and integer values

input always returns a string so the test is not necessary. In your case the result of type(age) != int will always be True so the first part if the if will always be executed. You can test age by converting to int and trapping the ValueError exception with a Try block.

commented: thanks man +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.