Skip to content

Commit 088ea6d

Browse files
committed
List, String
1 parent e3472c2 commit 088ea6d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ list_of_chars = list(<str>)
5555
```
5656

5757
```python
58-
<bool> = <el> in <collection> # For dictionary it checks if key exists.
5958
index = <list>.index(<el>) # Returns index of first occurrence or raises ValueError.
6059
<list>.insert(index, <el>) # Inserts item at index and moves the rest to the right.
6160
<el> = <list>.pop([index]) # Removes and returns item at index or from the end.
@@ -309,14 +308,15 @@ String
309308
```
310309

311310
```python
312-
<str> = <str>.replace(old, new [, count]) # Replaces 'old' with 'new' at most 'count' times.
311+
<bool> = <sub_str> in <str> # Checks if string contains a substring.
313312
<bool> = <str>.startswith(<sub_str>) # Pass tuple of strings for multiple options.
314313
<bool> = <str>.endswith(<sub_str>) # Pass tuple of strings for multiple options.
315314
<int> = <str>.find(<sub_str>) # Returns start index of first match or -1.
316315
<int> = <str>.index(<sub_str>) # Same but raises ValueError.
317316
```
318317

319318
```python
319+
<str> = <str>.replace(old, new [, count]) # Replaces 'old' with 'new' at most 'count' times.
320320
<bool> = <str>.isnumeric() # True if str contains only numeric characters.
321321
<list> = textwrap.wrap(<str>, width) # Nicely breaks string into lines.
322322
```

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ <h2 id="list"><a href="#list" name="list">#</a>List</h2>
237237
product_of_elems = functools.reduce(<span class="hljs-keyword">lambda</span> out, x: out * x, &lt;collection&gt;)
238238
list_of_chars = list(&lt;str&gt;)
239239
</code></pre>
240-
<pre><code class="python language-python hljs">&lt;bool&gt; = &lt;el&gt; <span class="hljs-keyword">in</span> &lt;collection&gt; <span class="hljs-comment"># For dictionary it checks if key exists.</span>
241-
index = &lt;list&gt;.index(&lt;el&gt;) <span class="hljs-comment"># Returns index of first occurrence or raises ValueError.</span>
240+
<pre><code class="python language-python hljs">index = &lt;list&gt;.index(&lt;el&gt;) <span class="hljs-comment"># Returns index of first occurrence or raises ValueError.</span>
242241
&lt;list&gt;.insert(index, &lt;el&gt;) <span class="hljs-comment"># Inserts item at index and moves the rest to the right.</span>
243242
&lt;el&gt; = &lt;list&gt;.pop([index]) <span class="hljs-comment"># Removes and returns item at index or from the end.</span>
244243
&lt;list&gt;.remove(&lt;el&gt;) <span class="hljs-comment"># Removes first occurrence of item or raises ValueError.</span>
@@ -411,13 +410,14 @@ <h2 id="string"><a href="#string" name="string">#</a>String</h2>
411410
&lt;list&gt; = &lt;str&gt;.splitlines(keepends=<span class="hljs-keyword">False</span>) <span class="hljs-comment"># Splits on line breaks. Keeps them if 'keepends'.</span>
412411
&lt;str&gt; = &lt;str&gt;.join(&lt;coll_of_strings&gt;) <span class="hljs-comment"># Joins elements using string as separator.</span>
413412
</code></pre>
414-
<pre><code class="python language-python hljs">&lt;str&gt; = &lt;str&gt;.replace(old, new [, count]) <span class="hljs-comment"># Replaces 'old' with 'new' at most 'count' times.</span>
413+
<pre><code class="python language-python hljs">&lt;bool&gt; = &lt;sub_str&gt; <span class="hljs-keyword">in</span> &lt;str&gt; <span class="hljs-comment"># Checks if string contains a substring.</span>
415414
&lt;bool&gt; = &lt;str&gt;.startswith(&lt;sub_str&gt;) <span class="hljs-comment"># Pass tuple of strings for multiple options.</span>
416415
&lt;bool&gt; = &lt;str&gt;.endswith(&lt;sub_str&gt;) <span class="hljs-comment"># Pass tuple of strings for multiple options.</span>
417416
&lt;int&gt; = &lt;str&gt;.find(&lt;sub_str&gt;) <span class="hljs-comment"># Returns start index of first match or -1.</span>
418417
&lt;int&gt; = &lt;str&gt;.index(&lt;sub_str&gt;) <span class="hljs-comment"># Same but raises ValueError.</span>
419418
</code></pre>
420-
<pre><code class="python language-python hljs">&lt;bool&gt; = &lt;str&gt;.isnumeric() <span class="hljs-comment"># True if str contains only numeric characters.</span>
419+
<pre><code class="python language-python hljs">&lt;str&gt; = &lt;str&gt;.replace(old, new [, count]) <span class="hljs-comment"># Replaces 'old' with 'new' at most 'count' times.</span>
420+
&lt;bool&gt; = &lt;str&gt;.isnumeric() <span class="hljs-comment"># True if str contains only numeric characters.</span>
421421
&lt;list&gt; = textwrap.wrap(&lt;str&gt;, width) <span class="hljs-comment"># Nicely breaks string into lines.</span>
422422
</code></pre>
423423
<ul>

0 commit comments

Comments
 (0)