I am using ipython notebook in ubantu version 16.04 and I run this code,
word = 'Rushiraj'
length = 0
for char in 'rushiraj':
length = length + 1
print('There are', length,'character')
The output you are seeing is due to the fact that you are using Python 2, but you're using the
In Python 2,
tuple as its first argument (so you are printing out the Python representation of a tuple).
You can fix this in two ways.
If you add
from __future__ import print_function to the top of your file, then
Alternately, you can call it like:
print 'There are', length,'character'