Python Forum
Variable from notepad problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variable from notepad problem
#1
Hello dear users, let me explain you my problem with variable.

b = open("test.txt", "r").readline()

a = input("Write")

if a == b:
print("good")

I have really simple program like this. In my "test.txt" i have only two lines and in first is "a" and in second "b"

If i put in my input "a" this if statement not work and not print "good". But when only try to print out print(b) it prints "a" so i do not understand why it is not working.

My variable b is equal to "a" but my if statement says it is not equal.

I also noticed when i have only one line in my notepad then it is working. So please guys can you help me with this ? Why it is not working when i have two lines in notepad.

Thank you a lot !
Reply


Messages In This Thread
Variable from notepad problem - by samuelbachorik - Apr-10-2020, 08:43 AM
RE: Variable from notepad problem - by ibreeden - Apr-10-2020, 09:01 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  dynamic variable name declaration in OOP style project problem jacksfrustration 3 830 Oct-22-2023, 10:05 PM
Last Post: deanhystad
Question Trouble installing modules/libraries and getting Notepad++ to show cyrillic letters Dragiev 6 2,311 Jul-24-2022, 12:55 PM
Last Post: Dragiev
  Reset Variable problem IcodeUser8 3 2,394 Jul-20-2020, 12:20 PM
Last Post: IcodeUser8
  Problem: Get variable JohnnyCoffee 0 1,622 Feb-22-2020, 09:26 PM
Last Post: JohnnyCoffee
  Problem defining a variable rix 6 3,250 Dec-17-2019, 11:34 AM
Last Post: rix
  Problem writing a variable value to Excel Chuck_Norwich 1 1,967 Jul-25-2019, 02:20 PM
Last Post: Chuck_Norwich
  Running python code meant for Notepad++ plugin independently greektranslator 3 3,031 Jan-28-2019, 06:03 PM
Last Post: maxtimbo
  Pass variable script return twice output problem Faruk 8 4,459 Dec-26-2018, 11:57 AM
Last Post: Faruk
  Exporting Python Output to Notepad Nirmal 4 3,640 Sep-02-2018, 02:36 PM
Last Post: Nirmal
  Problem with variable O_Pas_Sage 7 4,524 Aug-25-2018, 04:07 PM
Last Post: buran

Forum Jump:

User Panel Messages

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