Python Forum
Trying to compare string values in an if statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to compare string values in an if statement
#1
I am doing a tutorial where i get some string data input

lbsOrKgs = input ("is it in lbs or kgs")

now after getting that input all i want to do is write a comparison

if lbsOrKgs == ("lbs) or lbsOrKgs = ("kgs"):
print ("cool)

Getting error? Please help me understand. Thank you.
Reply
#2
== is comparison, = is assignment. Quotes come in pairs. Some of yours do not match up.

Please use python tags when posting code, otherwise the indenting is lost.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  need to compare 2 values in a nested dictionary jss 2 919 Nov-30-2023, 03:17 PM
Last Post: Pedroski55
  Loop through values and compare edroche3rd 6 743 Oct-18-2023, 04:04 PM
Last Post: edroche3rd
  Getting rid of old string values Pedroski55 3 1,071 Oct-11-2022, 10:56 PM
Last Post: Pedroski55
  mutable values to string items? fozz 15 2,968 Aug-30-2022, 07:20 PM
Last Post: deanhystad
  Compare variable with values in a file paulo79 1 1,148 Apr-22-2022, 03:16 AM
Last Post: Pedroski55
  String concatenation in SQL update statement hammer 3 1,572 Feb-24-2022, 08:00 PM
Last Post: hammer
  if statement string match javiopro 2 1,676 Sep-04-2021, 05:56 PM
Last Post: javiopro
  Compare each element of an array in a logic statement without using a for loop leocsmith 3 5,942 Apr-01-2021, 07:57 PM
Last Post: deanhystad
  Conceptualizing modulus. How to compare & communicate with values in a Dictionary Kaanyrvhok 7 4,072 Mar-15-2021, 05:43 PM
Last Post: Kaanyrvhok
Exclamation Compare values in a for loop. penahuse 1 2,391 Feb-22-2021, 07:01 AM
Last Post: buran

Forum Jump:

User Panel Messages

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