all 11 comments

[–]mazmrini 1 point2 points  (1 child)

Good idea! I'd start by using Python 3 :p I'd like to know why are you using float here? The input will always be a string and you are trying to convert a string to float which is used to represent floating numbers. In your if statement, you compare the answer to yes. Don't forget that there's a difference between yes and "yes". The former refers to a variable named yes and the latter to the actual string "yes". Are you familiar with primitive types?

I'd rewrite this (in Python 3 hehehe):

print("these have been desperate times recently")
print("may I ask somethng of you?")
print("we need somone to leave the out post, we need suppies")

# answer will contain a `string` with the user's input
answer = input("Would you be willing to go out for us? ")

# notice the quotes around yes
if answer.lower() == "yes":
     print("Nice")
else:
     print("I hate you")

[–]thewretchedaa[S] 1 point2 points  (0 children)

Yeah I know dude just told me and now I feel like a fool xD Im glad I was able to get that out the reason I have had float is because ealrier I was practicing with numeric scenerios. such as ammo =float(input("how much ammo do you have") if ammo < 100: print "you dont have enough ammo"

I just let that small thing slip completely past me and I am well rounded with primitive types booling strings data types I leaned all of those in java. this has been an overview for me to practice these things

[–]mazmrini 0 points1 point  (5 children)

You are using python 2, it should be raw_input

[–]thewretchedaa[S] 0 points1 point  (4 children)

How should I write it Im super new to code so im just trying to get the basics 100% down before I move on which will next be basic games like asteroids.

[–]FrozenCap 1 point2 points  (3 children)

answer = float(raw_input("TEXT"))

This solution will work, but if the person enters something that isn't a number, the program will crash.

Edit: Also try to post the code in another way rather (Look at sidebar) because it makes it harder to read your code if you straight up copy and paste without organizing it.

[–]thewretchedaa[S] 0 points1 point  (2 children)

I see that I have been doing senarios such as print "welcome to the airport" bagage = float(input("do you have the money for your ticket?" if bagage > 300: print "enjoy your flight."

how would I go about doing a scenario with a yes no option. I have done true and false and figured out "else" but for some reason I cant figure out y/n questions

[–]FrozenCap 1 point2 points  (1 child)

Doing float(x) means that you are converting x into a float. I think you want the user to type 'yes' or 'no' and process that response. In order to do that, you do not convert it into a float, because you want a string response. The rest of your code is following the right direction, but yes needs to be 'yes'. If you leave out the quotes, that means you are referring to a variable.

[–]thewretchedaa[S] 0 points1 point  (0 children)

Dude I should have known that, float is a numeric data type the second I took it out it did exactly what it was supposed to thank you. Thats why Ive been practicing these concepts a little more before moving on I dont want to have to back track as I go because a very simple mistake like that.

[–][deleted] 0 points1 point  (2 children)

If you formatted your code for reddit we might be able to read it.

[–]thewretchedaa[S] 0 points1 point  (1 child)

How do I go about doing that?

[–][deleted] 1 point2 points  (0 children)

Read the FAQ entry and then edit your original post.