• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with user input for string and integer  RSS feed

 
Pat Gareau
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am trying to create a program that will add strings to integers that the user input.

name = input("What programming language do you like? ")
print(" The programming language you like is " + name)

why = input("Why do you prefer using this language? ")
print(" The reason you prefer this language is " + why)

number1 = int(input("input a number please: "))
number2 = int(input("input a number please: "))

print("The programming language you like is " + name )


input()

how can i have both the strings and integers add to each other?
please help thank you.
 
Les Morgan
Rancher
Posts: 778
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure what you want to do from your descriptions:

You can already add Strings to Numbers using the overloaded "+" operator and the result is a String.  To add a number and a String and get a number result, you need to convert the String to the appropriate number you want to use Check the numeric type of your choice's API for that.

If you would like to give a better example of what you want, then I'm sure specific help can be rendered.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!