LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-25-2018, 06:50 PM   #1
MADprograms
LQ Newbie
 
Registered: Feb 2018
Posts: 1

Rep: Reputation: Disabled
Post Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> rank NameError: name 'rank' is not defined


I tried making a variable but whenever i type it in it gives my this error
(why are my indents not showing up on the page here ether)

print("If you want to take the Windows quiz please type main() (yes with the parentheses)")
def main():
import time

rank = 0
------------------------------------------------------------------
>>> rank
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
rank
NameError: name 'rank' is not defined
 
Old 02-26-2018, 06:39 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Moving this thread to the Programming forum to gain it better exposure.

You should summarize things a bit better You did note what your problem is in the title and posted code, however it seems as if you assumed people know what you're trying in advance. Sometimes better to state things more clearly in plain paragraph format and then show the supporting code and error following that.

As far as maintaining any formatting for code, you need to use BB Codes to encapsulate you code. See the ones for [code] blocks.

Resultant code properly surrounded by [code][/code] blocks will look like this example:
Code:
printf("Code example\n");
 
Old 02-26-2018, 01:43 PM   #3
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Welcome to LQ and to the Programming forum!

To preserve formatting place your code snippets inside [CODE]...[/CODE] tags. You may type those yourself or click the "#" button in the edit controls.

As rtmistler has pointed out, it is not at all clear what you are trying to do, to those willing to help. Remember that the better you describe your problem, the better the help you will receive.

What the error is telling you is that the object "rank" has not been defined within the interactive shell you are running. How that relates to the code snippet you pasted above is unknown to us.

Please review the Site FAQ for guidance in asking well formed questions, then try to re-state your question in a way that others can better understand.

Last edited by astrogeek; 02-26-2018 at 01:44 PM. Reason: tpos, typs, typos
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between "1R8 Single Rank 240 Pin" and "2R8 dual Rank 240 Pin" PatD Linux - Hardware 3 12-16-2017 12:33 PM
ValueError: max() arg is an empty sequence Traceback (most recent call last): File puru45 Ubuntu 1 11-25-2014 02:26 PM
Hostname defined in file "network" changes after change to file "hosts" qwkfish Linux - Networking 2 10-14-2009 04:07 PM
YUM Traceback (most recent call last): .... etusha Red Hat 0 01-09-2008 01:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration