# -*- coding: utf-8 -*-
"""
Created on Fri Oct 11 21:38:15 2019

@author: Faradars-pc2
"""

import json

def namayeshe_pass_zakhire_shode():
    """ pass zakhire shode ra namayesh bedeh."""
    esme_file = 'password.json'
    try:
        with open(esme_file) as f:
            password = json.load(f)
    except  FileNotFoundError:
        return None
    else:
        return password
    
def daryaft_pass_jadid():
    """ az karbar jadidi pass ra begir"""
    password = input('password ra vared konid: ')
    esme_file = 'password.json'
    with open(esme_file, 'w') as f:
        json.dump(password, f)
    return password    
        
def shenasaee_password():
    """ shenasaee password haye vared shode"""
    password = namayeshe_pass_zakhire_shode()
    if password:
        print(f'password shoma {password} bood')
    else:
        password = daryaft_pass_jadid()
        print(f'password taeen shode tavasote shoma: {password}')
        
shenasaee_password()       







