Jump to content

what is wrong with this python code?

forecaster1310
print("hello, type a number!")
num1 = int(input())
num2 = int(input())
if num1 < num2 == True:
    print(num1 + " is smaller then " + num2)
else:
    print(num2 + " is smaller then " + num1)
Link to comment
Share on other sites

Link to post
Share on other sites

Moved to Programming. Please post in the correct subforum in future.

CPU: Intel i7 6700k  | Motherboard: Gigabyte Z170x Gaming 5 | RAM: 2x16GB 3000MHz Corsair Vengeance LPX | GPU: Gigabyte Aorus GTX 1080ti | PSU: Corsair RM750x (2018) | Case: BeQuiet SilentBase 800 | Cooler: Arctic Freezer 34 eSports | SSD: Samsung 970 Evo 500GB + Samsung 840 500GB + Crucial MX500 2TB | Monitor: Acer Predator XB271HU + Samsung BX2450

Link to comment
Share on other sites

Link to post
Share on other sites

print("hello, type a number!")
num1 = int(input())
num2 = int(input())
if num1 < num2 == True:
    print(str(num1) + " is smaller then " + str(num2))
else:
    print(str(num2) + " is smaller then " + str(num1))

 

There is your working code. You cant combine int and string you have to convert the int into string.

I will recommend an NHu12s (or an NHd15 (maybe)) for your PC build. Quote or @ me @Prodigy_Smit for me to see your replies.

PSU Teir List | Howdy! A Windows Hello Alternative 

 

 

Desktop :

i7 8700 | Quadro P4000 8GB |  64gb 2933Mhz cl18 | 500 GB Samsung 960 Pro | 1tb SSD Samsung 850 evo

Laptop :

ASUS G14 | R9 5900hs | RTX 3060 | 16GB 3200Mhz | 1 TB SSD

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Smit Devrukhkar said:

print("hello, type a number!")
num1 = int(input())
num2 = int(input())
if num1 < num2 == True:
    print(str(num1) + " is smaller then " + str(num2))
else:
    print(str(num2) + " is smaller then " + str(num1))

 

There is your working code. You cant combine int and string you have to convert the int into string.

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Smit Devrukhkar said:

print("hello, type a number!")
num1 = int(input())
num2 = int(input())
if num1 < num2 == True:
    print(str(num1) + " is smaller then " + str(num2))
else:
    print(str(num2) + " is smaller then " + str(num1))

 

There is your working code. You cant combine int and string you have to convert the int into string.

but then if I write 5 and 3 it shows 5 is smaller then 3

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, forecaster1310 said:

but then if I write 5 and 3 it shows 5 is smaller then 3

Umm it works fine for me.

 

image.png.9f90f90ab932d4577f38646fddb75ce7.png

I will recommend an NHu12s (or an NHd15 (maybe)) for your PC build. Quote or @ me @Prodigy_Smit for me to see your replies.

PSU Teir List | Howdy! A Windows Hello Alternative 

 

 

Desktop :

i7 8700 | Quadro P4000 8GB |  64gb 2933Mhz cl18 | 500 GB Samsung 960 Pro | 1tb SSD Samsung 850 evo

Laptop :

ASUS G14 | R9 5900hs | RTX 3060 | 16GB 3200Mhz | 1 TB SSD

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×