Weird case example in Python

 def to_weird_case(string):  
   string= string.lower() #this is test  
   strlist = string.split()#[this, is, test]  
   result = []  
   slen = len(string)  
   for s in strlist:  
     slen= len(s)  
     for i in range(0,slen,2):  
       a = s[i].upper()  
       result.append(a)  
       if i+1 < slen:  
         r = s[i+1]  
         result.append(r)  
     result.append(' ')  
   return ''.join(result )  
 str = input('enter your string: ')  
 c = to_weird_case(str)  
 print(c)  

Post a Comment

0 Comments