How do I check for an EXACT word in a string in python

后端 未结 7 2057
再見小時候
再見小時候 2020-12-01 18:27

Basically I need to find a way to figure out a way to find the EXACT word in a string. All the information i have read online has only given me how to search for letters in

相关标签:
7条回答
  • 2020-12-01 19:04

    Use the comparison operator == instead of in then:

    if text == 'This is correct':
        print("Correct")
    

    This will check to see if the whole string is just 'This is correct'. If it isn't, it will be False

    0 讨论(0)
提交回复
热议问题