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."
Related Posts:
- What is the result of % in Python?
- Reading an Excel file in python using pandas
- Python Variable Declaration
- How do I compare two strings in python?
- Pip freeze vs. pip list
- How to read the last line of a file in Python?
- Python- Robot Framework Rebot Using List
- How to update/upgrade a package using pip?
- Python vs Cpython
- How do I update\upgrade pip itself from inside my virtual environment?
- Changing one character in a string
- How can I represent an ‘Enum’ in Python?
- IndexError: too many indices for array
- numpy array: IndexError: too many indices for array
- How do I specify new lines on Python, when writing on files?
- Relative imports – ModuleNotFoundError: No module named x
- bash: pip: command not found
- Using global variables in a function
- How do I check what version of Python is running my script?
- Converting integer to string in Python
- Python for-in loop preceded by a variable
- How do I upgrade the Python installation in Windows 10?
- What does if __name__ == “__main__”: do?
- Difference between del, remove, and pop on lists
- How can I install packages using pip according to the requirements.txt file from a local directory?
- How to measure elapsed time in Python?
- How to uninstall Anaconda completely from macOS
- Python: Start and stop timer [duplicate]
- not all arguments converted during string formatting.. NO % variables
- TypeError: ‘builtin_function_or_method’ object is not subscriptable
- Relative imports in Python 3
- ImportError: No module named sklearn.cross_validation
- ImportError: No module named sklearn.cross_validation
- How can I prevent the TypeError: list indices must be integers, not tuple when copying a python list to a numpy array?
- TypeError: ‘int’ object is not callable
- “pip install unroll”: “python setup.py egg_info” failed with error code 1
- Converting string into datetime
- ImportError: No module named matplotlib.pyplot
- working of \n in python [duplicate]
- ImportError: No module named matplotlib.pyplot
- How do I list all files of a directory?
- Accessing the index in ‘for’ loops?
- The difference between comparison to np.nan and isnull()
- Cannot find module cv2 when using OpenCV
- How do I parse a string to a float or int?
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- TypeError: cannot perform reduce with flexible type
- Could not find a version that satisfies the requirement tensorflow
- Local variable referenced before assignment?
- ImportError: numpy.core.multiarray failed to import
- pip or pip3 to install packages for Python 3?
- ImportError: numpy.core.multiarray failed to import
- How to remove \xa0 from string in Python?
- What is the meaning of [:] in python [duplicate]
- How to create a new text file using Python
- Unzip all zipped files in a folder to that same folder using Python 2.7.5
- TypeError: write() argument must be str, not bytes (Python 3 vs Python 2 )
- python socket.error: [Errno 98] Address already in use
- AttributeError(“‘str’ object has no attribute ‘read'”)
- Python Save to file
- ‘numpy.ndarray’ object has no attribute ‘index’
- Add list to set?
- ImportError: No module named scipy
- Checking whether pip is installed?
- Decoding UTF-8 strings in Python
- How to have an array of arrays in Python
- ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?
- Convert bytes to int?
- ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?
- AttributeError(“‘str’ object has no attribute ‘read'”)
- How to use 2to3 properly for python?
- Why does using from __future__ import print_function breaks Python2-style print?
- Python Error – int object has no attribute
- Loading a file with more than one line of JSON into Pandas
- How can I selectively escape percent (%) in Python strings?
- Type error Unhashable type:set
- How to have a set of sets in Python?
- Python: count repeated elements in the list
- How to join on multiple columns in Pyspark?
- Python3 Error: TypeError: Can’t convert ‘bytes’ object to str implicitly
- matplotlib: RuntimeError: Python is not installed as a framework
- urllib2.HTTPError: HTTP Error 403: Forbidden
- Convert a Unicode string to a string in Python (containing extra symbols)python string unicode type-conversion
- Fast ping sweep in python
- Numpy, multiply array with scalar
- TypeError: coercing to Unicode: need string or buffer, list found
- Python can’t find module NLTK
- ImportError: cannot import name NUMPY_MKL
- Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support
- TypeError: super() takes at least 1 argument (0 given) error is specific to any python version?
- Checking if a string can be converted to float in Python
- Convert string to variable name in python
- Adding +1 to a variable inside a function
- dump() missing 1 required positional argument: ‘fp’ in python json
- Installing scipy for python 2.7
- Install py2exe for python 2.7 over pip: this package requires Python 3.3 or later
- ImportError: No module named IPython
- How can I install a .egg Python package on Windows (attempt using easy_install not working)
- Symbol not found: __PyCodecInfo_GetIncrementalDecoder
- Cannot remove entries from nonexistent file