[Tutor] uplownumpnct.py

Ethan Rosenberg ethanrosenberg414 at gmail.com
Mon Jan 1 12:22:08 EST 2024


Tutor -

What is my syntax error?

#uplownumpnct.py
#To determine uppercase, lowercase, punctuation and special characters in a
string


up=
['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
numm = [1,2,3,4,5,6,7,8,9,0]
pnct = [:,;.,,]
spec = [!,@,<,#,>,},$,%,&,?,*,(,),{,/,' ']

sent = 'THIS is the way we wash 1 2 3 , , !'
list2 = list(sent)
lgn = len(sent)
lgn2 = lgn
print(lgn)

for i in range(0,lgn-1):
{
        if list2[i] in up:
            upp+=

       if list2[i] in  low:
            lww+=

       if list2[i]  in numm:
            numnum+=

       if list2[i] in pnct:
            numpct+=

       if list2[i] in spec:
            numspec+=

}

     prnt

def prnt:
     print('Num uppercase  ', upp)
     print('Num lowercase  ',lww)
     print('Num  numbers ',  numnum)
     print('Num  punctuation  ', numpnct)
     print('Num  special characters' , numspec)
           #uplownumpnct.py
#To determine uppercase, lowercase, punctuation and special characters in a
string


up=
['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
numm = [1,2,3,4,5,6,7,8,9,0]
pnct = [:,;.,,]
spec = [!,@,<,#,>,},$,%,&,?,*,(,),{,/,' ']

sent = 'THIS is the way we wash 1 2 3 , , !'
list2 = list(sent)
lgn = len(sent)
lgn2 = lgn
print(lgn)

for i in range(0,lgn-1):
{
        if list2[i] in up:
            upp+=

       if list2[i] in  low:
            lww+=

       if list2[i]  in numm:
            numnum+=

       if list2[i] in pnct:
            numpct+=

       if list2[i] in spec:
            numspec+=

}

     prnt

def prnt:
     print('Num uppercase  ', upp)
     print('Num lowercase  ',lww)
     print('Num  numbers ',  numnum)
     print('Num  punctuation  ', numpnct)
     print('Num  special characters' , numspec)


Ethan Rosenberg


More information about the Tutor mailing list