jeudi 5 avril 2018

See if new data equals old data, if old data equals new data do nothing. Else rename old data to new data

As my bad Title describes I want to check my if my new data equals my old data. If the new data equals old data: do nothing If the new data is not equal to old data: change old data to new data. Then repeat the whole process with the new definition for old data.

Made this code, but as you can see, every time old data is redefined at the end Its redefined again when running the code once more.

def ask_data_change():
    data_inn = 'old data'    
    my_data_input = input('What is your input?: ')


    if data_inn == my_data_input:
        #does nothing
        print('Data input is equal to existing data')
        print('data unchanged: ' + data_inn)
    else:
        #Changes data_inn to new data input
        data_inn = my_data_input
        print('Data is not equal to existing, changing data_inn to my_data_input')
        print('New data is now: ' + data_inn)


while True:
    ask_data_change()

Aucun commentaire:

Enregistrer un commentaire