MichalDK

WeirdCase

Jan 24th, 2021
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. def create_phone_number(n: list):
  2.     phone_no="(+"
  3.  
  4.     for a in range (len(n)):
  5.         phone_no += str(n[a])
  6.         if a == 1:
  7.             phone_no += (") ")
  8.         if a==4 or a==7:
  9.             phone_no+=("-")
  10.  
  11.     return phone_no
  12.  
  13. def to_weird_case(my_string: str):
  14.     weird=""
  15.     counter2=0
  16.     for a in range (len(my_string)):
  17.         temp = my_string[a]
  18.  
  19.         if ord(temp)==32:
  20.             counter2 = 0
  21.         else:
  22.             counter2 += 1
  23.  
  24.         if counter2%2:
  25.             temp2=temp.upper()
  26.             weird+=(temp2)
  27.         else :
  28.             temp2=temp.lower()
  29.             weird+=(temp2)
  30.  
  31.     return weird
  32.  
  33. print(to_weird_case("Ahoj lidi jak vam to jde"))
  34. print(create_phone_number([1,2,3,4,5,6,7,8,9,0,1]))
Advertisement
Add Comment
Please, Sign In to add comment