Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Python filter_list
Author
Message
Python #1
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:
[Image: hacker10.jpg]

Reply

RE: Python #2
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()

Reply

RE: Python #3
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
[Image: hacker10.jpg]

Reply

RE: Python #4
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.
[Image: 4180_gif_by_d53865-d31l0il.gif]


“If they ever tell my story let them say I walked with giants, men rise and fall like the Winter wheat but these names will never die...let them say I lived in the time of Achilles...”



Reply

RE: Python #5
i recommend the channel from LiveFaster a member of our HC community!

http://www.youtube.com/user/nerd2academia?gl=DE&hl=de
[Image: hacker10.jpg]

Reply

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

Reply

RE: Python #7
z = int(input ("Enter any number " ))
h = 5
y = z + h
print (y)
[Image: HJIAwEw.png]

Reply

RE: Python #8
Thx buddies Smile Happy to have u guys :-P
[Image: hacker10.jpg]

Reply

RE: Python #9
(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

Reply

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

Reply







Users browsing this thread: 1 Guest(s)