# Calculate the number of 1 and L in the string given
s="1lll1l1l1l1ll1l111ll1l1ll1l1ll1ll111ll1ll1ll1l1ll1ll1ll1ll1lll1l1l1l1l1l1l1l1l1l1l1l1ll1lll1l111ll1l1l1l1l1l1"
print "Length of String given is : ", len(s)
x,y=0,0
for n in range (0,len(s)):
if s[n]=='l':
x=x+1
else:
y=y+1
print "Number of times L appeared in the given string is : ", x
print "Number of times 1 appear in the given string is : ", y
# http://www.codeskulptor.org/#user21_ViL6RA4QrSkUWtF.py
==============
Console Output :
#Another way to do this is by a simple command :
import simplegui
string="1lll1l1l1l1ll1l111ll1l1ll1l1ll1ll111ll1ll1ll1l1ll1ll1ll1ll1lll1l1l1l1l1l1l1l1l1l1l1l1ll1lll1l111ll1l1l1l1l1l1"
x= string.count("l")
y= string.count("1")
print "Length of String given is : ", len(string)
print "Number of times L appeared in the given string is : ", x
print "Number of times 1 appear in the given string is : ", y
# http://www.codeskulptor.org/#user21_nK7oJgwPOe1IJUR.py
==============
Console Output Remains the same :
s="1lll1l1l1l1ll1l111ll1l1ll1l1ll1ll111ll1ll1ll1l1ll1ll1ll1ll1lll1l1l1l1l1l1l1l1l1l1l1l1ll1lll1l111ll1l1l1l1l1l1"
print "Length of String given is : ", len(s)
x,y=0,0
for n in range (0,len(s)):
if s[n]=='l':
x=x+1
else:
y=y+1
print "Number of times L appeared in the given string is : ", x
print "Number of times 1 appear in the given string is : ", y
# http://www.codeskulptor.org/#user21_ViL6RA4QrSkUWtF.py
==============
Console Output :
Length of String given is : 109 Number of times L appeared in the given string is : 61 Number of times 1 appear in the given string is : 48
#Another way to do this is by a simple command :
import simplegui
string="1lll1l1l1l1ll1l111ll1l1ll1l1ll1ll111ll1ll1ll1l1ll1ll1ll1ll1lll1l1l1l1l1l1l1l1l1l1l1l1ll1lll1l111ll1l1l1l1l1l1"
x= string.count("l")
y= string.count("1")
print "Length of String given is : ", len(string)
print "Number of times L appeared in the given string is : ", x
print "Number of times 1 appear in the given string is : ", y
==============
Console Output Remains the same :
Length of String given is : 109 Number of times L appeared in the given string is : 61 Number of times 1 appear in the given string is : 48