पायथन स्ट्रिंग एंडविथ () विधि
उदाहरण
जांचें कि क्या स्ट्रिंग विराम चिह्न (।) के साथ समाप्त होती है:
txt = "Hello, welcome to my world."
x = txt.endswith(".")
print(x)
परिभाषा और उपयोग
यदि स्ट्रिंग निर्दिष्ट मान के endswith()
साथ समाप्त होती है, तो विधि सही है, अन्यथा गलत है।
वाक्य - विन्यास
string.endswith(value, start, end)
पैरामीटर मान
Parameter | Description |
---|---|
value | Required. The value to check if the string ends with |
start | Optional. An Integer specifying at which position to start the search |
end | Optional. An Integer specifying at which position to end the search |
और ज्यादा उदाहरण
उदाहरण
जांचें कि क्या स्ट्रिंग "मेरी दुनिया" वाक्यांश के साथ समाप्त होती है।
txt = "Hello, welcome to my world."
x = txt.endswith("my world.")
print(x)
उदाहरण
जांचें कि क्या स्थिति 5 से 11 "मेरी दुनिया" वाक्यांश के साथ समाप्त होती है:
txt = "Hello, welcome to my world."
x = txt.endswith("my world.",
5, 11)
print(x)