Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

Python Help, I'm still new

MagnoliaNinja

New Coder
I was doing an assignment in my online coding class, and I'm not sure why it won't work, If you can fix this please help!
Line 27 is the error
Python:
import random
print("What is your first name?")
name1 = input("")
print("What shoes do you like?")
shoes1 = input("")
if shoes1 == (("converse") or ("Converse")):
    print("Nice, casual is always in!")
elif shoes1 == (("dudes") or ("Dudes")):
    print("Eh, they're nice but I wouldn't wear them in public.")
print("How old are you?")
age1 = int(input())
if age1 <= int(16):
    print("I hate you")
elif age1 >= int(17):
    print(str(age1) + (" is a good age to start exploring style."))
print("I think I know your style")
print("So, " + (name1) + ", what is your favorite top?")
top1 = input("")
if top1 == (("tshirt") or ("T-Shirt")):
    print("T-Shirts are fine, but nothing special")
elif top1 == (("Tshirt") or ("t-shirt")):
    print("T-Shirts are fine, but nothing special")
elif top1 == (("cum") or ("Cum") or ("CUM")):
    print("yeah, really funny a**hole")
print("What about your choice of bottom?")
bottom1 = input("")
Cargoresponse = random.randint[("How many kids?"), ("How old are you again?"), ("How's the wife?")]
if bottom1 == ("Cargo pants") or ("Cargo shorts") or ("Cargo Pants") or ("Cargo Shorts") or ("cargo pants") or ("cargo shorts"):
    print("How many kids?")
 
Last edited by a moderator:
Being "still new" does not excuse you from consulting the documentation. The function random.randint() takes two integers as parameters, not three strings. Whether that will make your code work, I could not say

Some tips for your next posts :
1) Always post code in code tags (*especially* Python code which is useless if the indentation is lost)
2) Always include the exact error message and location
 
As cbreemer suggested you should look over the documentation. The code is full of errors.
  • randint takes integers - start and end number
  • That is not the correct way of using the or comparison - should be (if item == True or item == True)
  • Not sure why you have everything in a tuple
  • Athough the print statement with the variables will work, should have a look at f-strings
 
Last edited:
Here is one way of doing it

Python:
answers = {
    'shoes': 'What shoes do you like?',
    'age': 'What is your age?',
    'top': 'What is your favorite top?',
    'bottom': 'What is your favorite bottom?'
}

for question, value in answers.items():
    print(value)
    answers[question] = input('>> ')

for question, answer in answers.items():
    print(f'{question} - {answer}')

output
Code:
What shoes do you like?
>> converse
What is your age?
>> 22
What is your favorite top?
>> tanktop
What is your favorite bottom?
>> jeans
shoes - converse
age - 22
top - tanktop
bottom - jeans
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom