Python 如何在print()中只打印名字

Python 如何在print()中只打印名字,python,if-statement,concatenation,Python,If Statement,Concatenation,我只想在这里打印名字,因此如果给定的名字是Don Jon,那么输出应该是“你可以驾驶Don”或“你不能驾驶Don”,因为你未成年你需要: a = input("Enter your Full Name ") b = int(input("Enter your age ")) if b >= 20: print("You can drive " + a) else: print("You can't drive " + a + " You are underage") 你需要: a

我只想在这里打印名字,因此如果给定的名字是Don Jon,那么输出应该是“你可以驾驶Don”或“你不能驾驶Don”,因为你未成年

你需要:

a = input("Enter your Full Name ")
b = int(input("Enter your age "))
if b >= 20:
  print("You can drive " + a)
else:
  print("You can't drive " + a + " You are underage")
你需要:

a = input("Enter your Full Name ")
b = int(input("Enter your age "))
if b >= 20:
  print("You can drive " + a)
else:
  print("You can't drive " + a + " You are underage")

您还可以使用
str.find()


您还可以使用
str.find()


@反社会者,请加上这个作为答案,尼克,请接受同样的答案,这样对其他人有帮助future@Sociopath,请将此添加为答案和尼克,请接受相同的答案,以便将来对其他人有所帮助
a = input("Enter your Full Name ")
b = int(input("Enter your age "))
if b >= 20:
  print("You can drive ", a[:a.find(" ")])
else:
  print("You can't drive " , a[:a.find(" ")]," You are underage")