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
  Calculate the sum of the differences inside tuple PUP280 4 1,228 Aug-12-2022, 07:20 PM
Last Post: deanhystad
  Can I check multi condition for 1 item in a easy way? korenron 4 1,610 May-01-2022, 12:43 PM
Last Post: deanhystad
  Sort Differences in 2.7 and 3.10 Explained dgrunwal 2 1,397 Apr-27-2022, 02:50 AM
Last Post: deanhystad
  Code to check folder and sub folders for new file and alert fioranosnake 2 1,986 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,363 Jun-29-2021, 08:21 PM
Last Post: RandomNameGenerator
  Can somebody check what is wrong with my code? hplus_liberation 4 2,651 Sep-16-2020, 05:52 AM
Last Post: perfringo
  How to compare two PDFs for differences Normanie 2 2,432 Jul-30-2020, 07:31 AM
Last Post: millpond
  else condition not called when if condition is false Sandz1286 10 5,956 Jun-05-2020, 05:01 PM
Last Post: ebolisa
  [HELP] Nested conditional? double condition followed by another condition. penahuse 25 8,213 Jun-01-2020, 06:00 PM
Last Post: penahuse
  Differential equations with initial condition in Python (change a working code) Euler2 1 1,861 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