简体   繁体   English

我做错了什么? (python帮助)

[英]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.

相关问题 我在这方面做错了什么? - What have I done wrong in this? pygame / Python的精灵不动? 我做错了什么? (无错误) - pygame/python sprite not moving? What have i done wrong? (no errors) 我在 Python 耦合 ODE 代码中做错了什么? - What Have I Done Wrong In My Python Coupled ODE code? python web scraper-我做错了什么? - python web scraper - what have I done wrong? 我不明白我在这里做错了什么 - I cannot understand what I have done wrong here 我在编写多项选择游戏时做错了什么 - What have I done wrong with programming a multiple choice game 这个用于提醒通知的 python 程序使计算机变慢,这里的代码有什么问题? 我已经完成 pip 安装 plyer - This python program for reminder notification slows down computer, what is wrong with the code here? I have already done pip install plyer 我在 python 中写的程序有什么问题? - What is wrong with the program I have written in python? 我正在编写将二进制数转换为十进制数的代码,这就是我所做的,有人可以告诉我哪里错了,(我进入 Python 1 个月 - I am making a code to turn a Binary number into decimal number, This is what I have done, Can someone tell where I am wrong, (i am 1 month into Python 我的日期时间格式不正确,我做错了什么? - My datetime isn't formatted correctly, what have I done wrong?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM