How to prevent WannaCry Ransomware from infecting your devices ?

Ransomware as the name suggest is a kind of malicious software that first find a way to get inside your device and then replicates itself to other devices by making your device as a host victim which ultimately results in asking victim users for ransom (money) in exchange of unlocking their files , it literally locks down all your files...