Advertisement
Riju21

6_condition

Mar 27th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. a = [1,2,12,4,5,6]
  2. summ = 0
  3. for a1 in a:
  4.     if a1==12:
  5.         a1 = 0
  6.         # print(a.index(a1))    # find the index number
  7.     summ+=a1  
  8.        
  9. print(summ)
  10. print('\n\n')
  11. print('simple condition:\n')
  12. mail = 'abc@gmail.com.bd'
  13. passs = True
  14. if mail == 'abc@gmail.com.bd' and passs:
  15.     print('success')
  16. elif mail == 'abc@gmail.com.bd' or passs:
  17.     print('mail or password required')
  18. else:
  19.     print('error')
  20.  
  21. print('\n\nobject: \n\n')
  22.  
  23. x = [2, 4, 5, 6]
  24. y = [2, 4, 5, 6]
  25.  
  26. print(x == y)  # list x and y is same
  27. print(x is y)  # x & y is different object
  28. print('id of x: ' + str(id(x)) + ' & id of y ' + str(id(y)))  # id of x & y
  29. x = y
  30. print(x is y)  # x & y is same object
  31. print('id of x: ' + str(id(x)) + ' & id of y ' + str(id(y)))  # id of x & y is same
  32.  
  33. s = mail.split('.')  # first split the mail according to '.'
  34. s2=[]                # empty array
  35. for s1 in s:
  36.     if s1=='bd':
  37.         s.remove(s1)  # remove the 'bd' from s list
  38.         s2 = s  # assing into new list
  39.  
  40. con = ''      
  41. for s3 in s2:
  42.     # print(s3)
  43.     con +=s3+','
  44. print(con[:-1])        # remove the last char ','
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement