[英]What have i done wrong? (python help)
The question i'm working on asks me to "write an expression whose value is the concatenation of the three str values associated with name1 , name2 , and name3" , separated by commas." "So if name1 , name2 , and name3 , were (respectively) "Neville", "Dean", and "Seamus", your expression's value would be "Neville,Dean,Seamus". 我正在研究的问题要求我“写一个表达式,其值是与name1,name2和name3关联的三个str值的串联”,并用逗号分隔。”“所以,如果name1,name2和name3是(分别)“ Neville”,“ Dean”和“ Seamus”,您的表达式的值为“ Neville,Dean,Seamus”。 "
“
The answer that i submitted is "name1,name2,name3" but when i click "submit" the message informs of a logical error within my code and that my expression didn't return the correct value. 我提交的答案是“ name1,name2,name3”,但是当我单击“提交”时,该消息会通知我的代码中存在逻辑错误,并且我的表达式未返回正确的值。 What have i done wrong?
我做错了什么?
Homework? 家庭作业? Did you submit the result of the expression, or the expression itself?
您提交表达式的结果还是表达式本身?
",".join([name1, name2, name3])
Or whatever you used? ",".join([name1, name2, name3])
还是您使用过的?
Edit: You mention that you submitted ("name1", "name2", "name3") - which would not return the concatenated names - but rather those stings. 编辑:您提到您提交了(“ name1”,“ name2”,“ name3”)-不会返回串联的名称-而是那些字符串。 If you wanted to do it like this (a little less elegant then the version I put above) you could try:
如果您想这样做(比我上面提到的版本少一些优雅),可以尝试:
name1 + "," + name2 + "," + name3
The difference being the quotations (") around the names - are stopping you from using the variables provided. 名称之间的引号(“)的区别-阻止您使用提供的变量。
Edit2: This is how I understand the question you were asked. Edit2:这就是我对您提出的问题的理解。 They want you to submit to them, an expression that will return the values assigned to the name1, name2 and name3 variables (whatever they may be) - There are two examples of such expressions above - which concatenate the three name variables, and add a comma between them - have you tried submitting either of the examples above?
他们希望您向他们提交一个表达式,该表达式将返回分配给name1,name2和name3变量的值(无论它们可能是什么)-上面有这样的表达式的两个示例-将三个name变量连接起来,并添加一个它们之间的逗号-您是否尝试过提交以上任一示例?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.