Advertisement
DrAungWinHtut

string1.py

Mar 12th, 2023
906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1.  
  2. def len_(s):
  3.     count = 0
  4.     for c in s:
  5.         count += 1
  6.     return count
  7.  
  8.  
  9. def reverse_(s):
  10.     ss = ''
  11.     size = len_(s)
  12.     for i in range(size):    # 0 - size-1
  13.         ss = ss + s[size-1-i]  # 9 8 7
  14.     print(ss)
  15.  
  16.  
  17. num = 423432
  18. str1 = '1234567890'
  19.  
  20. size = len_(str1)
  21. print(size)
  22. if size % 2 == 0:  # even
  23.     print('even')
  24.     mid2 = size//2
  25.     mid1 = mid2-1
  26.     print('{}{}'.format(str1[mid1], str1[mid2]))
  27. else:
  28.     print('odd')
  29.     mid = size//2
  30.     print(str1[mid])
  31.  
  32.  
  33. reverse_(str1)
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement