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 169 views
1 answer 130 views
1 answer 159 views
1 answer 230 views
1 answer 153 views
1 answer 200 views
...