简体   繁体   English

python Magic 8球使用函数

[英]python Magic 8 ball using functions

I'm trying to make Magic 8-ball using python Functions.我正在尝试使用 python 函数制作 Magic 8-ball。 How to print all three functions in one line ?如何在一行中打印所有三个功能? 在此处输入图片说明

The issue is the last line of answers:问题是最后一行答案:

" the Magic 8-Ball says:" + answers

You forgot to put parentheses after answers.你忘了在答案后加上括号。 Without them, it is trying to add the string to the answers function.没有它们,它会尝试将字符串添加到答案函数中。 With parentheses it will call answers() and append the return value.使用括号,它将调用 answers() 并附加返回值。

PS you might want a space after the colon after "says". PS,您可能需要在“says”之后的冒号后留一个空格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM