Python Forum
If statement containing apostrophe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If statement containing apostrophe
#10
You removed (see a note below) the new-line ending from the line from csv file (line 13), and then on line 30 you add new-line '\n' to user input on line 30. So they cannot be equal.

Now for the line 13 - it's not a problem in this particular case, but you replace '\n' with '', but depending on OS and the way you open the file, the new line may differ, e.g. '\r\n' vs '\n' vs '\r'. better use line = line.strip() or line = line.rstrip()
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
If statement containing apostrophe - by AshBax - Jul-08-2019, 10:57 AM
RE: If statement containing apostrophe - by AshBax - Jul-08-2019, 11:18 AM
RE: If statement containing apostrophe - by buran - Jul-08-2019, 11:31 AM
RE: If statement containing apostrophe - by AshBax - Jul-08-2019, 12:29 PM
RE: If statement containing apostrophe - by AshBax - Jul-09-2019, 09:09 AM
RE: If statement containing apostrophe - by ThomasL - Jul-09-2019, 11:25 AM
RE: If statement containing apostrophe - by buran - Jul-09-2019, 10:08 AM
RE: If statement containing apostrophe - by AshBax - Jul-09-2019, 01:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  CSV not printing apostrophe correctly bazcurtis 8 2,528 Aug-22-2022, 04:28 PM
Last Post: bazcurtis
  Is it possible to have an apostrophe inside { } in an f-string? Exsul 6 9,649 Sep-05-2019, 12:37 AM
Last Post: Exsul

Forum Jump:

User Panel Messages

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