Jump to content
  • Advertisement
Sign in to follow this  
Calcious

Kinda hard to explain this

This topic is 844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


subcores = ["AX43", "JOM10", "BALLS", "AYVOC", "PIZZA", "TITAN"]
cores = ["Fast", "Strong", "Balanced"]
Whole_Item = []
active = 1
add_item_active = 1
item_select = []
core_prompt = ("Select one of them, spell them exactly like it is spelled like." + "\n")
subcores_prompt = ("Select one of the core, spell them exactly like it is spelled like." + "\n")
add_item = ""
#####################





print("trash code below!\nThese are the cores available for you:")


for Cheese in cores:
	print("\t" + Cheese)
	
cheese_select = input(core_prompt)

if cheese_select in cores:
	print("Adding in " + cheese_select.title() + ".")
else:
	print("This isn't in the list, sorry.")
	active = 0
	
	
if active == 1:
	print("Now for the Sub Cores:")
	
	for Item in subcores:
		print("\t" + Item)
		
	item_holder = input(subcores_prompt)
	if item_holder in subcores:
		item_select.append(item_holder)
	else:
		print("This isn't an item, sorry.")
		active = 0
		
	if add_item_active == 1:
		add_item = input("Would you like to add  more items? If so, enter Yes. \n")
	
	while add_item == "Yes" or "yes":
		add_item_active = 0
		extra = input("Please select another sub core.\n")
		if extra in subcores:
			print(extra + " has been added!")
			item_select.append(extra)
		#checks again... if add_item is no or No, go to the if statement below. If Yes or yes, while loop still goes on
		add_item = input("Would you like to continue adding more items?.\n")		
if add_item == "No" or "no":
	print("This is your finalized core thingy:")
	item_select.append(cheese_select)
	Whole_Item = item_select[:]
	for whole in Whole_Item:	
		print("\t" + whole)

				
			
	

So I had to do a project for a python book and I made this. The last comment above should tie in with my current problem.

 

Even if I type in No or No, the while loop still goes on even though it should stop since it requires add_item to be "Yes" or "yes". 

 

(also, do if statements only run once?)

Edited by Calcious

Share this post


Link to post
Share on other sites
Advertisement

Also, this is wrong:

    item_holder = input(subcores_prompt)
    if item_holder in subcores:
        item_select.append(item_holder)
    else:
        print("This isn't an item, sorry.")
        active = 0
        
    if add_item_active == 1:

 

You're setting active to 0, you need to be setting add_item_active = 0

 

Good luck, and keep working at it!

Share this post


Link to post
Share on other sites

Just to mention, you can save some horizontal space and accomplish the same thing with a set and the in operator (good if you have lots of options):

while add_item in {"YES", "yes"}:

Instead of:

while add_item == "Yes" or add_item == "yes":
Edited by mrpeed

Share this post


Link to post
Share on other sites

I think the python book that I'm using isn't really going in depth. 

 

If you guys can recommend some books that has the right balance of complex and (intuition???), it would be great!

Share this post


Link to post
Share on other sites

LearnPython.org seems good but I don't know what some of the words are. I guess I can google those words.

Share this post


Link to post
Share on other sites

I think the python book that I'm using isn't really going in depth. 

 

If you guys can recommend some books that has the right balance of complex and (intuition???), it would be great!

"Right balance" is a personal thing. I don't think it is bad if you don't learn everything the first time.

Your primary aim is to be able to express what you want to do. The "or" with two "==" tests does that.

 

Once you can do that comfortably, you'll start to pick up new and smarter ways of doing things from other people suggesting alternative ways, or code or other books that you read. "in" is one such example, but Python has loads of them. It's an ever lasting process to improve your coding.

Share this post


Link to post
Share on other sites

It feels like I'm learning a programming language, not learning programming itself. The book I'm reading teaches python (and is for absolute beginners). You would think that an absolute beginner would learn the concepts behind programming?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!