Advertisement
DrAungWinHtut

string.py

Mar 12th, 2023
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1.  
  2. def is_float(s):
  3.     if s.isdigit():
  4.         return False
  5.     try:
  6.         float(s)
  7.         return True
  8.     except Exception as e:
  9.         return False
  10.  
  11.  
  12. str = '1279481'
  13.  
  14.  
  15. if len(str) % 2 == 0:
  16.     mid2 = len(str)//2
  17.     mid1 = mid2-1
  18.     print("{}{}".format(str[mid1], str[mid2]))
  19. else:
  20.     mid = len(str)//2
  21.     print(str[mid])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement