[英]I am trying to use the upper function for the input
我正在尝试输入用户输入的大写字母,但仅使问题大写
name = input("Please enter your name ".upper())
You are uppercasing the prompt , the string value passed to input()
. 您正在大写提示 ,将字符串值传递给input()
。 You need to uppercase the result , the value returned by the function: 您需要将result (该函数返回的值)大写:
name = input("Please enter your name ").upper()
Note the placement of the closing parentheses there. 注意此处的右括号的位置。
You could separate out the input()
call from the uppercasing: 您可以从大写字母中分离出input()
调用:
name = input("Please enter your name ")
name = name.upper()
if that makes it clearer for you. 如果这样可以使您更清楚。
In essence, your attempt did this instead: 本质上,您的尝试是这样做的:
prompt = "Please enter your name "
prompt = prompt.upper()
name = input(prompt)
which is why you see PLEASE ENTER YOUR NAME
on your screen when you run your code. 这就是为什么在运行代码时在屏幕上看到“ PLEASE ENTER YOUR NAME
原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.