char python code example

Example 1: chr() python

The chr() method returns a string representing 
a character whose Unicode code point is an integer.

print(chr(71), chr(101), 
chr(101), chr(107), 
chr(115), chr(32), 
chr(102), chr(111), 
chr(114),chr(32), 
chr(71), chr(101), 
chr(101), chr(107),  
chr(115)) 
-> G e e k s   f o r   G e e k s

Example 2: what does char mean in python

* for char simply means characters in Python

Example 3: python char at

>>> s = "python"
>>> s[3]
'h'
>>> s[6]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: string index out of range
>>> s[0]
'p'
>>> s[-1]
'n'
>>> s[-6]
'p'
>>> s[-7]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: string index out of range
>>>

Example 4: how to get any letter of a string python

Random = "Whatever"#you can put anything here
words2 = Random.split(" ")
print('number of letters:')#you can delete this line...
print(len(Random))#and this one. these lines just Tell you how many 
#letters there are
while True:#you can get rid of this loop if you want
    ask = int(input("what letter do you want?"))
    print(Random[ask-1])

Example 5: char in python

there is no dataype as char in python

Tags:

Php Example