I have a question for Python

Asked 2 years ago, Updated 2 years ago, 12 views

If you bring a text with the name of a listed company in Korea and have a specific company name, I'm implementing it to print ha, but somehow the result doesn't come up...

Corplist = open('listed company.txt', 'r')

a = Corplist.readlines()

for i in a:
    If a == "Woori Bank"
        print("ha")
    else:
        continue

python

2022-09-22 11:33

1 Answers

 #Put in the colon...Line field symbols such as \r\n are at the end of the read file line. 
#You can remove it using the rstrip method.
If a.rstrip() == "Woori Bank": 


2022-09-22 11:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.