Obține caractere specifice în șir python

Exemple de cod

8
0

N

string = 'This is a string'
print(string[0])
#output: 'T'
7
0

N

# Get First 3 character of a string in python
first_chars = sample_str[0:3] 
print('First 3 characters: ', first_chars)

# Output:
First 3 characters: Hel
1
0

N

yourString = "string"

if "s" in yourString:
  print("There is an S in your string")
  
if "s" not in yourString:
  print("There is no S in your string")

Pagini similare

Pagini similare cu exemple

În alte limbi

Această pagină este în alte limbi

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................