TypeError: ">” not supported between instances of "str' and int‘

I know I’m missing something with this code. Can someone please help me? I’m new to coding and I’ve struggling with this all day. I don’t want to keep emailing my instructor so maybe I can get help from here. I’m trying to get it to run through the if statements with user input and then calculate the amount but I don’t know what I’m missing.enter image description here

>Solution :

You should post code you’re asking about as text in your question.

Going over your code with some comments:

print("Welcome")  # no issue here, although Python default is single quotes, so 'Welcome'
print = input("Please enter company name:")

After that last line, print is a variable that has been assigned whatever text was entered by the user. (even if that text consists of digits, it’s still going to be a text)

A command like print("You total cost is:") will no longer work at this point, because print is no longer the name of a function, since you redefined it.

num = input("Please enter number of fiber cables requested:")

This is OK, but again, num has a text value. '123' is not the same as 123. You need to convert text into numbers to work with numbers, using something like int(num) or float(num).

print("You total cost is:")

The line is fine, but won’t work, since you redefined print.

if num > 500:
  cost = .5

This won’t work until you turn num into a number, for example:

if int(num) > 500:


num = int(num)
if num > 500:

Also, note that the default indentation depth for Python is 4 spaces. You would do well to start using that yourself. Your code will work if you don’t, but others you have to work with (including future you) will thank you for using standards.


print = ("Total cost:, num")

Not sure what you’re trying to do here. But assiging to print doesn’t print anything. And the value you’re assigning is just the string 'Total cost:, num'. If you want to include the value of a variable in a string, you could use an f-string:

print(f"Total cost: {num}")

Or print them like this:

print("Total cost:", num)  # there will be a space between printed values

Leave a Reply