Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.15 KB | None | 0 0
  1. num_count =None
  2. account=0
  3. True_False=False
  4. all_accounts=[
  5. {
  6. "username":"viktor",
  7. "password":"123123",
  8. "date of bird":"02.10.2020",
  9. "male or female":"male",
  10. "country":"Bulgaria",
  11. "interests":[["obicham zelenchuci"]],
  12. "messege":[["meh"],["stava"]],
  13. "send by":[["viktor"],["viktor02"]],
  14. },
  15. {
  16. "username":"viki",
  17. "password":"12312",
  18. "date of bird":"02.10.2020",
  19. "male or female":"male",
  20. "country":"Bulgaria",
  21. "interests":[["obicham zelenchuci"]],
  22. "messege":[["meh"],["stava"]],
  23. "send by":[["viktor"],["viktor02"]],
  24. }
  25.  
  26. ]
  27.  
  28. def register(all_accounts):
  29. new_account={}
  30. user_name = input("username :")
  31. password =input("password :")
  32. date_of_birth = input("date of birth :")
  33. male_or_female = input("male or female :")
  34. country=input("country :")
  35. interests=input("interests :")
  36. new_account={
  37. "username" : user_name ,
  38. "password" : password ,
  39. "date of bird" : date_of_birth,
  40. "male or female" : male_or_female,
  41. "country":country,
  42. "interests":interests,
  43. "messege":None,
  44. "send by":None
  45. }
  46. all_accounts.append(new_account)
  47.  
  48.  
  49. def log_in(all_accounts,True_False,account):
  50. num_count=0
  51. username=input("username ? ")
  52. password=input("password ? ")
  53. for users in range(len(all_accounts)):
  54. if username == all_accounts[num_count]["username"] and password == all_accounts[num_count]["password"]:
  55. True_False=True
  56.  
  57.  
  58. while True_False:
  59. answer=input("change , quit or message ? ")
  60. logged_in(all_accounts,account,answer)
  61. if answer =="quit":
  62. break
  63. num_count+=1
  64. account = num_count-1
  65.  
  66. if True_False==False:
  67. print("invailid password or username !!")
  68.  
  69.  
  70.  
  71.  
  72. def logged_in(all_accounts,account,answer):
  73. if answer == "message":
  74. question = input("see messages or send a message ")
  75. if question == "see messages":
  76. curr_user=0
  77. curr_mess=0
  78. for row in range(len(all_accounts[account]["send by"])):
  79. print(all_accounts[account]["send by"][curr_user][0],":",all_accounts[account]["messege"][curr_mess][0])
  80. curr_user+=1
  81. curr_mess+=1
  82. if question =="send message":
  83. user=0
  84. for row in range(len(all_accounts)):
  85. if all_accounts[user]["username"] == all_accounts[account]["username"]:
  86. user+=1
  87. else:
  88. print(all_accounts[user]["username"])
  89.  
  90. user+=1
  91. chose_user=input("Which do you want to send a message ")
  92. send_message = 0
  93. for row in range(len(all_accounts)):
  94. if chose_user==all_accounts[send_message]["username"]:
  95. message_send=input("message:")
  96. all_accounts[send_message]["messege"].append([message_send])
  97. all_accounts[send_message]["send by"].append([all_accounts[account]["username"]])
  98. send_message+=1
  99. else:
  100. print("there is no such user")
  101.  
  102.  
  103.  
  104. if answer=="change":
  105. answer_2 = input("what you need to change ? ")
  106. if answer_2=="password":
  107. curr_password=input("currect password :")
  108. conf_curr_password=input("confirmet currect password :")
  109. if curr_password == all_accounts[num_count-1]["password"] and conf_curr_password == all_accounts[num_count-1]["password"]:
  110. new_password=input("New password :")
  111. all_accounts[account]["password"]=new_password
  112. if answer_2 =="interests":
  113. change_interests(all_accounts,account)
  114.  
  115.  
  116. def change_interests(all_accounts,account):
  117.  
  118. print(all_accounts[account]["interests"])
  119. answer=input("add or remove interests ? ")
  120. if answer == "add":
  121. new_interests=input("New interests :")
  122. count_1=0
  123. for row in range(len(all_accounts[account]["interests"])):
  124. if new_interests == all_accounts[account]["interests"][count_1]:
  125. print("this interest already have it")
  126. break
  127. count_1+=1
  128. else:
  129. all_accounts[account]["interests"].append([new_interests])
  130. if answer == "remove" and len(all_accounts[account]["interests"])==0:
  131. print ("no interest to remove")
  132.  
  133. elif answer == "remove":
  134. remove_interests=int(input("interest which you want to remove "))
  135. all_accounts[account]["interests"].remove(all_accounts[account]["interests"][remove_interests-1])
  136. print(all_accounts[0]["interests"])
  137.  
  138.  
  139.  
  140. while True:
  141. answer = input ("login or register ? ")
  142. if answer == "register":
  143. register(all_accounts)
  144. if answer == "login":
  145. log_in(all_accounts,True_False,account)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement