Skip to content
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
36 changes: 35 additions & 1 deletion Python/PythonIntro.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,43 @@ rover.__doc__
dir(rover)
# [__dir__, __doc__, ..., 'bark', 'barks', 'is_happy', 'name', 'owner', 'wagging']
```
```
Python String
In Python, Strings are arrays of bytes representing Unicode characters. However, Python does not have a character data type, a single character is simply a string with a length of 1. Square brackets can be used to access elements of the string.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide an example of using square brackets to access elements of a string? Also, maybe change "elements" to something else, something that makes sense that the elements you're accessing are either single characters or substrings.. "P


```
```
Creating a String
Strings in Python can be created using single quotes or double quotes or even triple quotes.
```
`` Python Program for Creation of String
Creating a String with single Quotes
``
```py
String1 = 'Welcome to the Geeks World'
print("String with the use of Single Quotes: ")
print(String1)
```
Creating a String with double Quotes
```
String1 = "I'm a Geek"
print("\nString with the use of Double Quotes: ")
print(String1)
``` Creating a String with triple Quotes ```
String1 = '''I'm a Geek and I live in a world of "Geeks"'''
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it's important to mention why you might use these different ways of writing strings, like to avoid escaping the other set of quotes like you've demonstrated here.

print("\nString with the use of Triple Quotes: ")
print(String1)

``` Creating String with triple Quotes allows multiple lines```
String1 = '''Geeks
For
Life'''
Comment on lines +476 to +478
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you also mention that using three double quotes works as well?

print("\nCreating a multiline String: ")
print(String1)
```
```
[Go back](README.md) and learn about `async` and Red commands


```