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?
#5
A space is still a character so not the same as an empty string,
use the string method strip to remove leading and trailing white space.
print('' == '      '.strip())
print('' == ' '.strip())
print('' == '  test    '.strip())
Output:
True True False
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 Yoriz - May-12-2019, 04:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare 2 files for duplicates and save the differences cubangt 2 1,038 Sep-12-2024, 03:55 PM
Last Post: cubangt
  how can I organise my code : best practice? pythonbum 0 616 May-24-2024, 03:17 PM
Last Post: pythonbum
  Calculate the sum of the differences inside tuple PUP280 4 2,375 Aug-12-2022, 07:20 PM
Last Post: deanhystad
  Can I check multi condition for 1 item in a easy way? korenron 4 2,543 May-01-2022, 12:43 PM
Last Post: deanhystad
  Sort Differences in 2.7 and 3.10 Explained dgrunwal 2 2,068 Apr-27-2022, 02:50 AM
Last Post: deanhystad
  Code to check folder and sub folders for new file and alert fioranosnake 2 3,049 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 3,328 Jun-29-2021, 08:21 PM
Last Post: RandomNameGenerator
  Can somebody check what is wrong with my code? hplus_liberation 4 3,621 Sep-16-2020, 05:52 AM
Last Post: perfringo
  How to compare two PDFs for differences Normanie 2 3,266 Jul-30-2020, 07:31 AM
Last Post: millpond
  else condition not called when if condition is false Sandz1286 10 7,994 Jun-05-2020, 05:01 PM
Last Post: ebolisa

Forum Jump:

User Panel Messages

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