Sinisterly
Python - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Python (https://sinister.ly/Forum-Python)
+--- Thread: Python (/Thread-Python--47578)

Pages: 1 2


Python - IDetox - 02-24-2013

Hi guys started with Python today (im a noob i know) Biggrin
Got the following problem.

I type: z= input ("enteranynumber")

before i initialized h=5 etc..

When i try to write z+h it says:

Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
z+2
TypeError: Can't convert 'int' object to str implicitly

Some1 got any ideas? Confusedurprised:


RE: Python - Guxi - 02-24-2013

User input will bi taken as string (str), you are trying to do math with string and integer, which cannot be possible.
If user inputs number 5, it will be string "5", not 5.

All you need to do is convert it to integer:
Code:
int(z)+h

Or it might be opposite problem. Solution is same
Code:
str()



RE: Python - IDetox - 02-24-2013

Im an Idiot :-D Im thinking what mistake ive done and its so easy :-P Thx anyway for showing me how dumb i am :-D


RE: Python - diana32 - 02-24-2013

Well-nobody is born and already knows everithing.I suggest you to take a look on youtube-there is many tutorial that can help you.


RE: Python - IDetox - 02-24-2013

i recommend the channel from LiveFaster a member of our HC community!

http://www.youtube.com/user/nerd2academia?gl=DE&hl=de


RE: Python - BunnyJ - 02-25-2013

Quick answer:
z = int(input("Enter a number -> ))
print (z)


RE: Python - LoneDevil - 02-25-2013

z = int(input ("Enter any number " ))
h = 5
y = z + h
print (y)


RE: Python - IDetox - 02-25-2013

Thx buddies Smile Happy to have u guys :-P


RE: Python - BunnyJ - 02-25-2013

(02-25-2013, 12:28 AM)IDetox Wrote: Thx buddies Smile Happy to have u guys :-P

Glad to help.. have fun with Python. I like it as well.
Jeff


RE: Python - Nailo - 02-25-2013

python is a excellent programming language for beginners if you have any more problems post on the forums or pm me champion.