so hi I am a complete noob at python and only started learning the basics I tried to create many random things which seem to work but I have no idea how to make this one work, as I said before I am a total noob so don't scold me
>>> def Love():
B=int(len(input("please put your name:")))
G=int(len(input("please put the name og your love interest:")))
print("your compatibillity is" + B-G + "%...")
p.s i am using python v.3.6.2
Inside the print function, you are using string concatenation. Since it's a string concatenation B - G produce integer which is not a string.
(Aug-29-2017, 08:43 PM)wavic Wrote: [ -> ]Inside the print function, you are using string concatenation. Since it's a string concatenation B - G produce integer which is not a string.
im sorry but as i said before i am a noob so can you please make it easier to understand for me, i am sooo sorry for being a pain
In the print() function you are telling Python to concatenate (add) two strings, 'B' and 'G', yet you have defined them as integers.
>>> x = 'hello'
>>> y = 'world'
>>> x + y
'helloworld'
>>>
Since you are using Python 3.6.2, you should look into formatting. So your print() function would look like this:
print("your compatibillity is {} %".format(B + G))
Also, you have defined a function "Love", which you do not use. If B, G and "print" are meant to be part of the function, they need to be properly indented and the function called:
def love():
B = int(len(input("please put your name: ")))
G = int(len(input("please put the name of your love interest: ")))
print("your compatibility is {} %".format(B + G))
love()
Output:
C:\Python36\python.exe C:/Python/Games/scratch.py
please put your name:joe
please put the name og your love interest:sally
your compatibility is 8 %
Alternatively you can use String formatters, %s
def love():
B = int(len(input("please put your name: ")))
G = int(len(input("please put the name of your love interest: ")))
print("your compatibility is %s" % str(B-G))
love()
(Aug-29-2017, 09:11 PM)sparkz_alot Wrote: [ -> ]In the print() function you are telling Python to concatenate (add) two strings, 'B' and 'G', yet you have defined them as integers.
>>> x = 'hello'
>>> y = 'world'
>>> x + y
'helloworld'
>>>
Since you are using Python 3.6.2, you should look into formatting. So your print() function would look like this:
print("your compatibillity is {} %".format(B + G))
Also, you have defined a function "Love", which you do not use. If B, G and "print" are meant to be part of the function, they need to be properly indented and the function called:
def love():
B = int(len(input("please put your name: ")))
G = int(len(input("please put the name of your love interest: ")))
print("your compatibility is {} %".format(B + G))
love()
Output:
C:\Python36\python.exe C:/Python/Games/scratch.py
please put your name:joe
please put the name og your love interest:sally
your compatibility is 8 %
thx dude ur awesome!! i understand now and i think i will mess around with this... Thx again!
![Dance Dance](https://python-forum.io/images/smilies/eusa_dance.gif)
What I have said is that you adding the result of B - G which is integer to the end of the string using string concatenation - the '+' sign. But in order to do that you have to turn the result to an string first: print("your compatibillity is" + str(B-G) + "%...")
. Or just to use string formatting that was proposed already.
i think i finally found out how to do it XP
def Love():
def Love():
b=int(len(input("put in your name please: ")))
g=int(len(input("please put in the name of your crush: ")))
l=int(((((b*4)**4)-b**2)-g**5)+((((g*3)**2)-g**2)-b**4))
b=int(l/9000)
print("--------------------------------------------------------------------------")
print("your love compatibillity is " + str(b) + "%; Disclaimer: this is not accurate at all")
yay