0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

「“p”以降に”q”がある」の表現方法

Posted at

思考プロセス

“p”以降に”q”がある=”p”以降の文字列に”q”が含まれる
find()で”p”のインデックスを特定し、スライス構文で以降の文字列を取得、「特定の文字が含まれるか」の判定を行う。

s = "abcpdefqgh"

print("q" in s[s.find("p") + 1:])  # True("p" 以降の "defqgh" に "q" がある)
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?