Homework Help Question & Answers

Throwing the error: can only concatenate str (not "int") to str age = input('Greetings! How old...

Throwing the error: can only concatenate str (not "int") to str

age = input('Greetings! How old are you?: ')
age = int(age) + 1
print("Happy birthday to you! You are" + age + 'years old!')

0 0
Next > < Previous
ReportAnswer #1

The input we're taking is considered as a string by compiler. Though we're trying to typecast it to int it's not changing so instead of doing that Change first two lines as below

age=int(input("Greetings! How old are you?: "))

age=age+1

Problem solved.

Know the answer?
Add Answer of:
Throwing the error: can only concatenate str (not "int") to str age = input('Greetings! How old...
Your Answer: Your Name: What's your source?
Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What is wrong with my python code. I am receiving this error: Traceback (most recent call...

    What is wrong with my python code. I am receiving this error: Traceback (most recent call last): File "C:/Users/owner/Documents/numberfive.py", line 7, in if age > 18: TypeError: unorderable types: str() > int() My code is age= input("Enter your age:") if age > 18: print("You can vote.") else: print("You can't vote.") if age > 64: print ("You're a Senior Citizen...you deserve two votes") endofprogram = input("Please hit enter to exit from this program:")

  • Python debug. (Registration error) Hi, can you help me debug the error code, and how can I fix it...

    Python debug. (Registration error) Hi, can you help me debug the error code, and how can I fix it? Thank you very much! 4 import sqlite: 5 conn sqlite3.connect("OS_Employee.db") 7 withconn: 8 curconn.cursor() try: 10 # Take user input for Employee-ID. Error checks it. Makes sure it's not taken. EmployeeID = input ("Please enter a employee ID: ") First_Nameinput("Please enter the employee's first name: ") Last Nameinput("Please enter the employee's last name: ") Email-input ("Please enter the employee's email: ")...

  • Write a program named ComputeAge that determines the user's age in years, months, and days +...

    Write a program named ComputeAge that determines the user's age in years, months, and days. The user enters his or her birthday (Using Scanner),and the program determines how old the person is on the current date. The following example shows what the user will see on the screen, assumingthat the current date is July 9, 1999:Enter the year you were born: 1980Enter the month you were born (1-12): 7Enter the day you were born: 26You are 18 years, 11 months,...

  • 2. This question is about processing strings 2.1 [4 marks] Given a string str, we can...

    2. This question is about processing strings 2.1 [4 marks] Given a string str, we can calculate a checksum of the string by summing up the ASCII codes of the characters in the string. For example, the checksum of a string "apple" is 530, which equals to 'a' + 'p' + 'p' + 'l' + 'e' = 97 + 112 + 112 + 108 + 101. Write a function int calculate_checksum(char str[] that calculates and returns the checksum of the...

  • Need help with C++ program // find() function sample input: hello there world sample output: if f...

    need help with C++ program // find() function sample input: hello there world sample output: if f is entered(which accesses the find function), user enters a letter they would like to find how many times it occurred in the string, for example: e. and it should outputs: 3 occurrences #include <iostream> #include <string.h> #include <string> using namespace std; #define MAX 512 struct node { char c; struct node *next; }; node *str = NULL; node *addOnto(struct node *list, char *a)...

  • Python: def combo(): play = True while play: x = int(input('How many people\'s information would you...

    Python: def combo(): play = True while play: x = int(input('How many people\'s information would you like to see: ')) print()    for num in range(x): name() age() hobby() job() phone() print()       answer = input("Would you like to try again?(Enter Yes or No): ").lower()    while True: if answer == 'yes': play = True break elif answer == 'no': play = False break else: answer = input('Incorrect option. Type "YES" to try again or "NO" to leave": ').lower()...

  • 1. How input stream works: consider the following program that reads the age and name of person...

    1. How input stream works: consider the following program that reads the age and name of person from the keyboard and display them.import java.util.Scanner;public class dataInput{public static void main (String[] args){String name; // Name of the userint age;Scanner scan = new Scanner(System.in);System.out.print ("Enter your age: ");age = scan.nextInt();System.out.print ("Enter your name:");name = scan.nextLine();System.out.println(name + " you are " + age + " years old");}}Type, compile and run the program.a) When it asks for input enter 45 and press enter key....

  • java program error

    I am recieving the following errors for the program listed below, can someone help out.java:112: variable declawed might not have been initializedjava:112: variable age might not have been initializedjava:115: variable name might not have been initializedonce compiled and working correctly I should get the program to print out and allow user input for each cat, then after input for all three cats has been inputted, theprogram is supposed to print out the following report:Names of cats >=3 that have clawsNameage/**********************************************************************************************************CatClawsProg.java**This...

  • My current age to be used in the problem: 20 years old. My next birthday: October...

    My current age to be used in the problem: 20 years old. My next birthday: October 15th, 2020 Last digit in student code: 4. ,,I=_ Possible Points: 8 possible points (added to Exam 1 score) Helpful Hint: Begin by making a number line to help structure the problem. Count the dates you will deposit/withdraw from the account. This will help ensure you have the number of payments correct. Requirements: 1. (4 points) Using your present age, calculate the annual deposit...

  • C++(invalid input for my program ( calculator) )

    x.øi5nt face="Arial">I have made a calculator with C++ , but I want to make some inputs in the program as invalid inputs.there are a number of error checks which are:Error check 1: number of parameters:the number of arguments should be only 3 : first number , second number , Operator inputif there are more than 3 or lessthe output should be ' P '.Error Check 2 : Valid number input:if paramenter 2 and 3 connot be converted into a valid...

Free Homework App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
Share Your Knowledge

Post an Article
Post an Answer
Post a Question with Answer

Self-promotion: Authors have the chance of a link back to their own personal blogs or social media profile pages.