Python Forum
[split] NameError: name 'lo' is not defined when using input ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] NameError: name 'lo' is not defined when using input ?
#1
Hi, i have another error that i can't solve :
Error:
Vite ! Des aliens envahissent la planète. Tu dois activer la plateforme de défense mondiale. J'espère que tu connais le mot de passe... () ------------------------------------------------- BIENVENUE DANS LA DEFENSE MONDIALE ------------------------------------------------- () Entre le mot de passe : lo Traceback (most recent call last): File "./Aliens.py", line 13, in <module> deviner = input("Entre le mot de passe : ").upper() File "<string>", line 1, in <module> NameError: name 'lo' is not defined
Here is the script :
#!/usr/bin/env python
# -*-coding:Latin-1 -*
aliens = 2
motDePasse = "ALIENS"
print("Vite ! Des aliens envahissent la planète.")
print("Tu dois activer la plateforme de défense mondiale.")
print("J'espère que tu connais le mot de passe...")
print()
print("-------------------------------------------------")
print("      BIENVENUE DANS LA DEFENSE MONDIALE         ")
print("-------------------------------------------------")
print()
deviner = input("Entre le mot de passe : ").upper()
while deviner != motDePasse:
    print()
    print("MOT DE PASSE INCORRECT.")
    print()
    aliens = aliens ** 2
    print("Il y a", aliens, "aliens sur Terre. Réessaie !")
    if aliens > 7400000000:
        break
    print()
    print("Indice mot de passe : les créatures qui nous attaquent.")
    print()
    deviner = input("Vite ! Entre le mot de passe : ").upper()
if aliens > 7400000000:
    print("Nooon ! Les aliens sont plus nombreux que nous. Tout est perdu.")
else:
    print("Hourra ! Nous avons gagné le combat, le monde est sauvé !")
Reply
#2
It looks like you are trying to use python 3 code with python 2, in python 2 input needs replacing with raw_input
Reply
#3
Thanks
I've added 3 at the end of this line :
#!/usr/bin/env python
It works. Thx for the tips !
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  “NameError” “is not defined” script that I know works on other computers iamwithstupid 0 70 Nov-24-2020, 04:23 PM
Last Post: iamwithstupid
  NameError: name 'L2' is not defined soshelby 5 166 Nov-05-2020, 08:50 PM
Last Post: soshelby
  NameError: name 'target_id' is not defined bhagyashree 7 291 Nov-03-2020, 10:22 AM
Last Post: bhagyashree
  code not working, NameError: name 's' is not defined ridgerunnersjw 4 438 Oct-05-2020, 07:03 PM
Last Post: buran
  Going thru tutorials..."NameError: name 'raw_input' is not defined" hmonnier 4 573 Jul-14-2020, 02:19 PM
Last Post: BitPythoner
  NameError: name 'pins' is not defined glennford49 2 800 Jun-15-2020, 12:20 PM
Last Post: glennford49
  python library not defined in user defined function johnEmScott 2 432 May-30-2020, 04:14 AM
Last Post: DT2000
  [split] NameError: name 'formats' is not defined shobhu123 1 632 May-24-2020, 06:29 PM
Last Post: Skaperen
  NameError: name 'cross_validation' is not defined tmhsa 5 1,819 Apr-21-2020, 08:15 PM
Last Post: DT2000
  Split and sort input file aawaleh 4 555 Apr-10-2020, 09:59 PM
Last Post: aawaleh

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020