Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > Python

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-02-2013, 10:05 AM   PM User | #1
kieranlavelle
New to the CF scene

 
Join Date: Mar 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
kieranlavelle is an unknown quantity at this point
Python function problem

Can someone please explain to me why this is not working.

def x():
u = input("Please enter your name: ")
x()
Please enter your name: Kieran
print(u)

Name Error: Name 'u' is not defined.

How do i go about defining a variable whilst creating a function?
ps I am new to python and coding in general as im sure you can tell.
kieranlavelle is offline   Reply With Quote
Old 03-02-2013, 10:28 AM   PM User | #2
kieranlavelle
New to the CF scene

 
Join Date: Mar 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
kieranlavelle is an unknown quantity at this point
Ahh I see now, the variable is local. Is there anyway I can use these variables outside of the function itself?
kieranlavelle is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:52 AM.


Advertisement
Log in to turn off these ads.