Infinite Loops and Examples in Python
Infinite Loops and Examples in Python
str=input("Enter a string")
v=c=d=s=0 ==================== RESTART: F:/Python
for char in str: ex/countvnumsp.py ====================
if char in "aeiou":v+=1
Enter a stringwelcom_python@class1234
Number of vowels= 4
if char in "bcdfghjklmnpqrstvwxyz":c+=1
Number of digits= 4
if char in "0123456789":d+=1
Number of Consonants= 13
if char in "&#@":s+=1 Number of Special Characters= 1
print("Number of vowels=",v) >>>
print("Number of digits=",d)
print("Number of Consonants=",c)
print("Number of Special Characters=",s)
4
SWAP FIRST TWO
CHARACTERS BETWEEN TWO
STRING
str=input("Enter first string:")
str2=input("Enter second string:")
print(str2[:2]+str[2:])
print(str[:2]+str2[2:])