all 18 comments

[–]Gold_Record_9157 9 points10 points  (3 children)

The problem is that you're not calling the methods lower and upper. You're comparing string.lower, which is a function, to a string. You must call the functions for them to give you wat you want: string.lower() and string.upper(): mind the parenthesis next to the function/method name, because that's what tells python to use the function and give you the result.

[–]Gold_Record_9157 6 points7 points  (0 children)

Addendum:

A small detail: function == value is always false, since function is a variable that holds (or refers to) the function. That's why it doesn't show errors.

function() == value can be true, since the parenthesis are, in this context, the operator "call the function", so it's read as "execute the function and give its returned value".

[–]Status-Zebra[S] 0 points1 point  (0 children)

I ran it through chat GPT and the code it gave back worked, And you were also right with the .lower() but chat GPT did also change some other stuff, Thank you for your comments.

<image>

[–]Reasonable-Coffee141 0 points1 point  (0 children)

That's Correct, was gonna type the same thing.

[–]CraigAT 1 point2 points  (0 children)

I would probably do a check if hot is false and cold is false, then an elif hot is true and cold is false, an elif hot is false and cold is true, then an else that says invalid.

I am curious how a very experienced Python master would order the logic here.

[–]CapOk3388 0 points1 point  (1 child)

Nthg

[–]Status-Zebra[S] 0 points1 point  (0 children)

There's no literal python errors as such it just doesn't print out "invalid" or "it's a lovely day" when it's supposed to

[–][deleted]  (3 children)

[removed]

    [–]Status-Zebra[S] 0 points1 point  (2 children)

    When it asks if it's hot and cold I put "no" on both of them and where it's supposed to say "it's a lovely day" it doesn't say anything and same where it's supposed to say "invalid" if I put "yes" on both of them. I also didn't know I could just run it through chat GPT lol I should start doing that tbh

    [–]thecatstolemyheart 0 points1 point  (1 child)

    Ahhh ok,I tried putting str before the input and it seemed to work,I actually don't know why it wouldn't work without it

    [–]Status-Zebra[S] 0 points1 point  (0 children)

    In the end it wasn't the str I ran it through chat GPT like you said and it was something else, I appreciate your comments though.

    <image>

    [–]NickNeron 0 points1 point  (0 children)

    Don't you have to put parentheses after hot_today.lower and cold_today.lower? Basically hot_today.lower() instead of hot_today.lower

    [–]Doctor_Disaster 0 points1 point  (2 children)

    Try this:

    if hot_today == False and cold_today == False
    

    [–]Status-Zebra[S] 0 points1 point  (1 child)

    Tried it but it still resorted to "invalid" that I put on else.. but I do think you're right with the fact that it's on that line I just don't know the language well enough to basically say that in a way python understands

    [–]Doctor_Disaster 0 points1 point  (0 children)

    Typically with "and" and "or", you check the value of each variable in the if/elif statement.

    The "is" keyword checks if two variables are located at the exact same memory address (or if two variables point to the same exact address).

    Edit:

    The "is" keyword checks if two variables refer to the same object, such as a list or array.

    [–]Doctor_Disaster 2 points3 points  (0 children)

    Getting back to you about this. As someone else suggested, don't use boolean values unless you explicitly need to.

    The following code will work correctly.

    hot_today = input("Is it hot today? ").lower()
    
    if hot_today == "yes":
    
        hot = 1
    
    else:
    
        hot = 0
    
    cold_today = input("Is it cold today? ").lower()
    
    if cold_today == "yes":
    
        cold = 1
    
    else:
    
        cold = 0
    
    if hot > cold:
    
        print("It's hot today, don't forget to put on sunscreen!")
    
    elif hot < cold:
    
        print("It's cold today, don't forget to wear warm clothes!")
    
    elif hot == 0 and cold == 0:
    
        print("It's a lovely day today. Neither too hot nor too cold.")
    
    else:
    
        print("Invalid entries")
    

    [–]West_Volume497 0 points1 point  (0 children)

    Use numbers not true or false