Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6849609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:00:47+00:00 2026-05-27T01:00:47+00:00

I was trying a simple piece of code, get someone’s name and age and

  • 0

I was trying a simple piece of code, get someone’s name and age and let him/her know when they turn 21… not considering negatives and all that, just random.

I keep getting this 'int' object is not subscriptable error.

name1 = raw_input("What's your name? ")
age1 = raw_input ("how old are you? ")
x = 0
int([x[age1]])
twentyone = 21 - x
print "Hi, " + name1+ " you will be 21 in: " + twentyone + " years."
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[34], line 4
      2 age1 = input ("how old are you? ")
      3 x = 0
----> 4 int([x[age1]])
      5 twentyone = 21 - x
      6 print "Hi, " + name1+ " you will be 21 in: " + twentyone + " years."

TypeError: 'int' object is not subscriptable
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:00:47+00:00Added an answer on May 27, 2026 at 1:00 am

    The problem is in the line,

    int([x[age1]])
    

    What you want is

    x = int(age1)
    

    You also need to convert the int to a string for the output…

    print "Hi, " + name1+ " you will be 21 in: " + str(twentyone) + " years."
    

    The complete script looks like,

    name1 = raw_input("What's your name? ")
    age1 = raw_input ("how old are you? ")
    x = 0
    x = int(age1)
    twentyone = 21 - x
    print "Hi, " + name1+ " you will be 21 in: " + str(twentyone) + " years."
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get some simple piece of code I found on a website
i am trying to compile this very simple piece of code class myList {
I am trying to run this seemingly simple piece of code which is repeated
Hi I'm trying to write a piece of code for a simple verification method
I am trying to get the following piece of code to work in a
I have spent hours trying to get my head around a piece of code
I'm trying to code a simple, sufficiently accurate filter for validating a piece of
I am trying to write a simple piece of Jquery in which the script
I'm trying to create a fairly simple piece of JavaScript that displays a random
I'm trying to get my head round Unit Testing and there's one more piece

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.