【发布时间】:2018-08-15 13:33:46
【问题描述】:
我将在此处添加几张图片,以便更易于可视化。我正在制作一个项目,一种矿物目录等。虽然我已经设法把所有东西都写好了,但出于某种原因,当它询问你是否想查找另一个时,它没有t 环回?我什至不确定完整的问题是什么,我只有一两个月的经验。
我在 Python 3.6 的整个代码中都使用了 IF 和 ELIF 语句,但是对于我的一生,我只是不知道如何在每个晶体或矿物之后保持恒定(是/否)流,你可以要求阅读另一个。
这里是代码:
import time
def moreCrystals():
print("Would you like to find out about another crystal?")
choice = input("Yes or No?").lower()
if choice == "yes":
choiceMore = input
crystal = input("Please enter a crystal name").lower()
crystal = input
else:
print("Thanks for using Space Statue's Crystal Directory!")
time.sleep(1)
print("Please come back soon to fufil your crystal needs!")
print(""" Welcome to Space Statue's Crystal Directory!
Simply type in a crystal name or type,
and we will do the rest! This directory will
tell you the following about the chosen crystal:
1. It's Properties and Meaning.
2. A brief description of the mineral.
3. Where it orginates/comes from in the world.
4. The mineral's rarity level.
I hope that this directory helps fufil your crystal
needs! """)
crystal = input("Please enter a crystal name").lower()
if crystal == "opal":
print(""" Opal. Also known as Opalite.
----------------------------
keywords - ORIGINALITY // CREATIVITY // CONFIDENCE //
COMFORTABILITY //
----------------------------
Properties: Most commonly a blue, translusent stone. Can have
coloured flashes of all shades. Looks like a dragon egg. It is
the birth stone of those who fall under the Star Sign Libra.
Meaning: A stone that inspires originality and boosts creativity.
The energy of the stone encourages confidence and being comfortable
within yourself. Being a highly absorbent energy stone, Opal will
take your emotions, thoughts and feelings, magnify them and send
them back to you, so use this stone in moments of positivity and
confidence.
Origins: Australia, Mexico, Brazil, Indonesia,
Czech Republic, Ethiopia and USA.
Rarity level: common """)
moreCrystals()
elif crystal == "tourmaline":
print(""" Tourmaline.
----------------------------
keywords - UNDERSTANDING // INSPIRATION // COMPASSION //
TOLERANCE // PROSPERITY // BALANCING MALE-FEMALE ENERGY //
ENHANCES ENERGY //
----------------------------
Properties: It is made from a crystal silicate mineral. It is
most commonly black, but can range from brown, violet, green, pink,
or in a dual-coloured pink and green.
Meaning: Tourmaline aids in understanding oneself and others.
It promotes self-confidence and diminishes fear. Tourmaline attracts
inspiration, compassion, tolerance and prosperity. It balances the
right-left sides of the brain. Helps treat paranoia, overcomes
dyslexia and improves hand-eye coordination. Tourmaline releases tension,
making it helpful for spinal adjustments. It balances male-female energy
within the body. Enhances energy and removes blockages.
Origins: Afghanistan, Pakistan, Russia, Burma, Sri Lanka and the
United States.
Rarity level: Between common and uncommon. """)
moreCrystals()
代码还有更多内容,但这是允许您输入另一个水晶的循环。但它没有。
【问题讨论】:
-
你似乎还有第二条
crystal = input行 -
您将内置的
input()函数分配给choiceMore和crystal。 -
请尽量减少您的代码 sn-ps。有助于问题或解决方案的长字符串,因此您应该缩短它们。它会阻止人们调查您的问题。
-
@gal242 我对编码还很陌生,所以我不确定你的意思?
-
@gal242 哦,我明白了...我的道歉,以及编码我对这个网站还是相当新的,我会记住的!