Creating Python Code With If Else Statement In R