print('That Alice's friend')
---------------------------------
print(r'That Alice's friend')
-----------------------------
string_name = "morning"
for element in string_name:
print(element, end=' ')
---------------------------
str = "morning"
i=0
while i<len(str):
print(str[i], end=' ')
i=i+1
---------------------
string_name = 'good morning'
count=0
# Iterate over the string
for element in string_name:
if element=='o':
count=count+1
print(count)
--------------------
str='hai good morning'
new=''
for char in str:
if char in 'aeiouAEIOU':
new +='*'
else:
new+=char
print(new)
---------------------------
dict={'letters':0,'upper':0,'lower':0,'Digits':0}
str1=input('enter a string')
for i in str1:
if i.isalpha():
dict['letters']+=1
if i.isupper():
dict['upper']+=1
if i.islower():
dict['lower']+=1
if i.isdecimal():
dict['Digits']+=1
print(dict)
-------------------------------
str='hai good morning hai hai�
str1=str.split()
str1
dict={}
for i in str1:
if i in dict:
dict[i]+=1
else:
dict[i]=1
print(dict)
-------------------------------
str='This is an the apple'
str=str.split('the')
print(str)
''.join(str)
-------------------------
name='Mahender Singh Dhoni'
name=name.split()
print(name)
new=name[0][0]+'.'+name[1][0]+'.'+name[2]
print(new))
-----------------------
sentence=' Chikkmaglur is very beautiful place'
sentence=sentence.split()
print(sentence)
max=sentence[0]
max_len=len(sentence[0])
for i in sentence:
if(len(i)>max_len):
max_len=len(i)
max=i
print('Largest word is: ',max)
min=sentence[0]
min_len=len(sentence[0])
for i in sentence:
if(len(i)<min_len):
min_len=len(i)
min =i
print('Smallest word is: ',min)
Output:
['Chikkmaglur', 'is', 'very', 'beautiful', 'place']
Largest word is: Chikkmaglur
Smallest word is: is
---------------------------------
Picnic={'Sandwitch':4,'apples':12,'cups':4,'cookies':8000}
print('PICNICITEMS'.center(20,'-'))
for k,v in Picnic.items():
print(k.ljust(12,'.')+ str(v).rjust(8))
--------------------------------------
def printPicnic(itemsDict,leftWidth,rightWidth):
print('PICNICITEMS'.center(leftWidth+rightWidth,'-'))
for k,v in itemsDict.items():
print(k.ljust(leftWidth,'.')+str(v).rjust(rightWidth))
picnicItems={'sandwiches':4,'apples':12,'cups':4,'cookies':8000}
printPicnic(picnicItems,12,5)
----------------------------------
list=['*','**','***','*****','*******','*********']
for i in list:
print(i.center(9,'-'))
----------------------------
str='good good morning good good'
str.strip('good')
str.rstrip('good')
str.lstrip('good')
------------------------------
PASSWORDS = {'email' : 'JKL:DF234@#$', 'twitter' : 'asd;lfjk@#$', 'youtube' :
'asldkjf;sljf234'}
import sys, pyperclip
if len(sys.argv) <2:
print('Usage: python pw.py [account] - copy account password')
sys.exit()
account = sys.argv[1] #first command line arg is the account name
if account in PASSWORDS:
pyperclip.copy(PASSWORDS[account])
print('Password ' + account + ' copied to clipboard.')
else:
print('There is no account named ' + account)
---------------------------------
import pyperclip
text = pyperclip.paste()
# Separate lines and add stars.
lines = text.split('\n')
for i in range(len(lines)): # loop through all indexes for "lines" list
lines[i] = �* ' + lines[i] # add star to each string in "lines" list
text = '\n'.join(lines)
pyperclip.copy(text)
-------------------------------
Lists of animals
Lists of aquarium life
Lists of biologists by author abbreviation
Lists of cultivars
-----------------------------------
string=input(("Enter a string:"))
if(string==string[::-1]):
������print("The string is a palindrome")
else:
������print("Not a palindrome")
--------------------------------------