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
  I'm getting a NameError: ...not defined. vonArre 2 163 Mar-24-2024, 10:25 PM
Last Post: vonArre
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 1,054 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
Question Take user input and split files using 7z in python askfriends 2 1,030 Dec-11-2022, 07:39 PM
Last Post: snippsat
  Getting NameError for a function that is defined JonWayn 2 1,056 Dec-11-2022, 01:53 PM
Last Post: JonWayn
Question Help with function - encryption - messages - NameError: name 'message' is not defined MrKnd94 4 2,776 Nov-11-2022, 09:03 PM
Last Post: deanhystad
  [split] NameError: name 'csvwriter' is not defined. Did you mean: 'writer'? cathy12 4 3,202 Sep-01-2022, 07:41 PM
Last Post: deanhystad
  How to split the input taken from user into a single character? mHosseinDS86 3 1,137 Aug-17-2022, 12:43 PM
Last Post: Pedroski55
  NameError: name ‘app_ctrl’ is not defined 3lnyn0 0 1,457 Jul-04-2022, 08:08 PM
Last Post: 3lnyn0
  NameError: name 'hash_value_x_t' is not defined Anldra12 5 1,864 May-13-2022, 03:37 PM
Last Post: deanhystad
  NameError: name 'cross_validation' is not defined tmhsa 6 13,182 Jan-17-2022, 09:53 PM
Last Post: TropicalHeat

Forum Jump:

User Panel Messages

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