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: name 'u1' is not defined (on parser code Python) Melcu54 1 132 Jul-26-2021, 04:36 PM
Last Post: snippsat
  I am getting a NameError that is not defined and not sure why it happen rick0922 5 390 Jun-14-2021, 03:41 PM
Last Post: deanhystad
  [split] NameError: name 'start_with_first_selected' is not defined knoxvilles_joker 4 595 Apr-18-2021, 07:59 PM
Last Post: knoxvilles_joker
  “NameError” “is not defined” script that I know works on other computers iamwithstupid 0 580 Nov-24-2020, 04:23 PM
Last Post: iamwithstupid
  NameError: name 'L2' is not defined soshelby 5 968 Nov-05-2020, 08:50 PM
Last Post: soshelby
  NameError: name 'target_id' is not defined bhagyashree 7 904 Nov-03-2020, 10:22 AM
Last Post: bhagyashree
  code not working, NameError: name 's' is not defined ridgerunnersjw 4 1,033 Oct-05-2020, 07:03 PM
Last Post: buran
  Going thru tutorials..."NameError: name 'raw_input' is not defined" hmonnier 4 1,150 Jul-14-2020, 02:19 PM
Last Post: BitPythoner
  NameError: name 'pins' is not defined glennford49 2 1,604 Jun-15-2020, 12:20 PM
Last Post: glennford49
  python library not defined in user defined function johnEmScott 2 862 May-30-2020, 04:14 AM
Last Post: DT2000

Forum Jump:

User Panel Messages

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