[英]The function str() is not working and I do not know what to do
I have the code:我有代码:
def rides(x):
return list(str(x))
When I input the word hi without any quotes当我输入单词 hi 时不带任何引号
It returns the error that hi is not defined它返回 hi 未定义的错误
However when input integers or hi with quotes it works, but I need it to work for hi without quotes.但是,当输入整数或带引号的 hi 时,它可以工作,但我需要它在不带引号的情况下为 hi 工作。
When your input is hi
without quotes, it means you pass a variable named hi
to your function.当您的输入是不带引号的hi
时,这意味着您将一个名为hi
的变量传递给您的 function。 If you don't define such variable before passing it to your function, your code will fail during it's evaluation with NameError
error.如果您在将此类变量传递给 function 之前未定义此类变量,则您的代码将在评估期间因NameError
错误而失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.