Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Need help with my scripiting homework

Featured Replies

So I keep trying for my script to ask the user to input a valid number if ones not given or in my case 0-99

It doesn't do this though. the gender.lower() stuff works fine and if I do alien as my input it asks me the question again until I type in either male or female. The only thing I need help with is why my age>=0 and age <=105 isn't working the way its supposed to be

 

Please help! due tomorrow! procrastinated this one big!

 

 

#ask for age + gender input
age = input ('How old are you? ')
gender = input (' male or female? ')
#turn age into integer
age = int (age)

#use while to keep asking for a valid input
while age >= 0 and age <= 105 and gender.lower() == 'male' and gender.lower() == 'female' :
    age = input ('Choose a valid age (0-99) ')
    age = int (age)
    gender = input ('male or female? ')
if age >= 0 and age <= 5 :
    print ('Fish')
elif age > 6 and age <= 15 and gender.lower() == 'male':
     print ('Gecko')
elif age > 6 and age <= 15 and gender.lower() == 'female':
     print ('Bunny')
elif age > 16 and age <= 30 and gender.lower() == 'male':
      print ('Snake')
elif age > 16 and age <= 30 and gender.lower() == 'female':
    print ('Parrot')
elif age > 30 and age <= 105 and gender.lower() == 'male':
     print ('Dog')
elif age > 30 and age <= 105 and gender.lower() == 'female':
        print ('Cat')

    
#thank you message
print()
print ('Thanks for using Pet Finder!')
 

 

 

Thank you for everyone helping me out!

 

Edit: results

 

How old are you? 55
 male or female? male
Dog

Thanks for using Pet Finder!

 

 

How old are you? 5555
 male or female? male

Thanks for using Pet Finder!

 

(It's suppose to ask the user for a valid number)

 

Edit2: language =python

Edited by xgate

while age >= 0 and age <= 105 and gender.lower() == 'male' and gender.lower() == 'female' :

 

^Here you specify that your age has to be from 0 to 105 and the gender has to be male and female.

For the while loop to work if you have the wrong age input you'll have to do it like this:

 

while age <= -1 and age >=106 and (gender.lower() == 'male' or gender.lower() == 'female' ):

 

EDIT: this is purely based upon my java knowledge, I've never worked with Python before. So feel free to correct me if I'm wrong.

  • Author

while age >= 0 and age <= 105 and gender.lower() == 'male' and gender.lower() == 'female' :

 

^Here you specify that your age has to be from 0 to 105 and the gender has to be male and female.

For the while loop to work if you have the wrong age input you'll have to do it like this:

 

while age <= -1 and age >=106 and (gender.lower() == 'male' or gender.lower() == 'female' ):

 

EDIT: this is purely based upon my java knowledge, I've never worked with Python before. So feel free to correct me if I'm wrong.

 

Tried this but it didn't ask the user to input a number again if it was over 105

 

I'm in chat if you want to come there to try and help me

 

edit: Also now doesn't prompt user to input again if gender wasn't male or female

Edited by xgate

Tried this but it didn't ask the user to input a number again if it was over 105

 

I'm in chat if you want to come there to try and help me

while (age <= -1 or age >=106) and (gender.lower() == 'male' or gender.lower() == 'female' ):

 

Sorry my bad, your age obviously can't both be under 0 and over 105, it had to be an 'or' instead of an 'and'.

  • Author

Dex fixed my age problem but now gender isn't working correctly :(

  • Author

Dex solved this for me

Great guy

 

while (age <= -1 or age >=106) or(gender.lower() != 'male' and gender.lower() != 'female' ) :
    age = input ('Choose a valid age (0-105) ')
    age = int (age)
    gender = input ('male or female? ')
if age >= 0 and age <= 5 :
    print ('Fish')
elif age > 6 and age <= 15 and gender.lower() == 'male':
    print ('Gecko')
elif age > 6 and age <= 15 and gender.lower() == 'female':
    print ('Bunny')
elif age > 16 and age <= 30 and gender.lower() == 'male':
    print ('Snake')
elif age > 16 and age <= 30 and gender.lower() == 'female':
    print ('Parrot')
elif age > 30 and age <= 105 and gender.lower() == 'male':
    print ('Dog')
elif age > 30 and age <= 105 and gender.lower() == 'female':
    print ('Cat')
 

Dex solved this for me

Great guy

 

while (age <= -1 or age >=106) or(gender.lower() != 'male' and gender.lower() != 'female' ) :

    age = input ('Choose a valid age (0-105) ')

    age = int (age)

    gender = input ('male or female? ')

if age >= 0 and age <= 5 :

    print ('Fish')

elif age > 6 and age <= 15 and gender.lower() == 'male':

    print ('Gecko')

elif age > 6 and age <= 15 and gender.lower() == 'female':

    print ('Bunny')

elif age > 16 and age <= 30 and gender.lower() == 'male':

    print ('Snake')

elif age > 16 and age <= 30 and gender.lower() == 'female':

    print ('Parrot')

elif age > 30 and age <= 105 and gender.lower() == 'male':

    print ('Dog')

elif age > 30 and age <= 105 and gender.lower() == 'female':

    print ('Cat')

 

Once again, you're welcome :)

 

Locked upon request.

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.