How to get char from string by index in Python

2 Answers

0 votes
s = "python programming"
print(s[0])
print(s[len(s) - 1])

'''
run:

p
g

'''

 



answered Jun 3, 2015 by avibootz
0 votes
s = "python programming"
for i in range(0, len(s)):
    print(s[i])

'''
run:

p
y
t
h
o
n

p
r
o
g
r
a
m
m
i
n
g

'''

 



answered Jun 3, 2015 by avibootz

Related questions

1 answer 154 views
1 answer 118 views
1 answer 150 views
1 answer 208 views
1 answer 144 views
1 answer 191 views
...