Python Forum
Condition check differences and how to organise code?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Condition check differences and how to organise code?
#4
ok so I changed the code

def find_filter_output(output,find):
    files = []
    lines = output.split("\n")
    contains = False
    found = False
    findStr = str(find)

    if findStr == "":
        word = "invalid"
        files.append(word)
        return files
here I test to see if findStr is empty by saying if findStr == "", this works great but I noticed when I put a space in between the "" it does not work or become true

so

 if findStr == " "
will give a boolean false value even if findStr is empty, so why does adding a blank space between "" make a difference? I thought that even if I had countless of blank spaces between the "" it would still be an empty string no?
Reply


Messages In This Thread
RE: Strings and more - by Larz60+ - May-12-2019, 12:21 AM
RE: Strings and more - by Yoriz - May-12-2019, 10:03 AM
RE: Condition check differences and how to organise code? - by adam2020 - May-12-2019, 02:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Calculate the sum of the differences inside tuple PUP280 4 1,244 Aug-12-2022, 07:20 PM
Last Post: deanhystad
  Can I check multi condition for 1 item in a easy way? korenron 4 1,629 May-01-2022, 12:43 PM
Last Post: deanhystad
  Sort Differences in 2.7 and 3.10 Explained dgrunwal 2 1,412 Apr-27-2022, 02:50 AM
Last Post: deanhystad
  Code to check folder and sub folders for new file and alert fioranosnake 2 2,008 Jan-06-2022, 05:03 PM
Last Post: deanhystad
  Try,Except,Else to check that user has entered either y or n (Code block pasted) RandomNameGenerator 3 2,375 Jun-29-2021, 08:21 PM
Last Post: RandomNameGenerator
  Can somebody check what is wrong with my code? hplus_liberation 4 2,664 Sep-16-2020, 05:52 AM
Last Post: perfringo
  How to compare two PDFs for differences Normanie 2 2,450 Jul-30-2020, 07:31 AM
Last Post: millpond
  else condition not called when if condition is false Sandz1286 10 6,034 Jun-05-2020, 05:01 PM
Last Post: ebolisa
  [HELP] Nested conditional? double condition followed by another condition. penahuse 25 8,293 Jun-01-2020, 06:00 PM
Last Post: penahuse
  Differential equations with initial condition in Python (change a working code) Euler2 1 1,869 May-29-2020, 04:06 PM
Last Post: Euler2

Forum Jump:

User Panel Messages

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