Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/strings #163

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/strings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Now if you want to multiline strings you have to use triple single/double quotes
write many lines


We can have two string literals side by side, and it will behave like a single string. For example
We can have two string literals side by side, and it will behave like a single string. For example:

::

Expand Down Expand Up @@ -95,7 +95,7 @@ Every string object is having couple of builtin methods available, we already sa
>>> s.isalnum()
True

Because of the space in the first line *isalnum()* returned *False* , it checks for all characters are alpha numeric or not.
Because of the space in the first line *isalnum()* returned *False*, it checks for all characters are alpha numeric or not.

::

Expand All @@ -106,7 +106,7 @@ Because of the space in the first line *isalnum()* returned *False* , it checks
>>> s.isalpha()
False

*isalpha()* checkes for only alphabets.
*isalpha()* checks for only alphabets.

::

Expand All @@ -123,7 +123,7 @@ Because of the space in the first line *isalnum()* returned *False* , it checks
>>> s.isupper() # To check if characters are in upper case or not
True

To split any string we have *split()*. It takes a string as an argument , depending on that it will split the main string and returns a list containing splitted strings.
To split any string we have *split()*. It takes a string as an argument, depending on that it will split the main string and returns a list of the words in the string.

::

Expand Down Expand Up @@ -198,7 +198,7 @@ Palindrome are the kind of strings which are same from left or right whichever w
else:
print("The string is not a palindrome")

The output
The output:

::

Expand All @@ -212,15 +212,15 @@ The output
Number of words
===============

In this example we will count the number of words in a given line
In this example we will count the number of words in a given line:

::

#!/usr/bin/env python3
s = input("Enter a line: ")
print("The number of words in the line are %d" % (len(s.split(" "))))

The output
The output:
::

$ ./countwords.py
Expand Down