Riju21

6_condition

Mar 27th, 2019
122
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. passs = True
  13. if mail == '[email protected]' and passs:
  14.     print('success')
  15. elif mail == '[email protected]' or passs:
  16.     print('mail or password required')
  17. else:
  18.     print('error')
  19.  
  20. print('\n\nobject: \n\n')
  21.  
  22. x = [2, 4, 5, 6]
  23. y = [2, 4, 5, 6]
  24.  
  25. print(x == y)  # list x and y is same
  26. print(x is y)  # x & y is different object
  27. print('id of x: ' + str(id(x)) + ' & id of y ' + str(id(y)))  # id of x & y
  28. x = y
  29. print(x is y)  # x & y is same object
  30. print('id of x: ' + str(id(x)) + ' & id of y ' + str(id(y)))  # id of x & y is same
  31.  
  32. s = mail.split('.')  # first split the mail according to '.'
  33. s2=[]                # empty array
  34. for s1 in s:
  35.     if s1=='bd':
  36.         s.remove(s1)  # remove the 'bd' from s list
  37.         s2 = s  # assing into new list
  38.  
  39. con = ''      
  40. for s3 in s2:
  41.     # print(s3)
  42.     con +=s3+','
  43. print(con[:-1])        # remove the last char ','
Advertisement
Add Comment
Please, Sign In to add comment