jimscore=int(input())
jerryscore=int(input())
要求使用三元操作符result=x if y else y判断赢家,并输出赢家姓名jim或jerry
三元操作符只能输出jimscore或jerryscore
怎样把他们变成输出赢家姓名啊?前面是固定的不可改动。
jimscore = int(input())
jerryscore = int(input())
print('jim' if jimscore > jerryscore else 'jerry')
你好,你可以使用以下代码:
jimscore = int(input())
jerryscore = int(input())
winner = (jimscore > jerryscore) and 'jim' or 'jerry'
print(f"赢家是{winner}")
输出结果为:
赢家是jim