Python Forum
python wont recognize indentation
Thread Rating:
  • 3 Vote(s) - 2.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python wont recognize indentation
#1
Hi,

My problem is as follows:

In the python 3.6 program, I have my code. Every thing works fine right up until line 94 (here its on line 28) where for some reason when I hit ENTER after the ':' at the end of an 'if' statement, the indentation seems to be off set. Below you can see that I have indented it correctly, but even when I do so in python, it still highlights the ':'. I'm wondering if I might have touched something on the FORMAT tab up-top.

Is this possible?

def my_pizza():
    print('\nGreat! Please select your pizza by imputting\nthe corresponding number?\n')
    time.sleep(2)
    for i, t in pizzas.items():
        print(i + ': ' + t)          # shows pizza list

        pizza = input()

    while pizza not in pizzas.keys():
        print('that is not an option')
        
        pizza = input()
        
    if pizza in pizzas.keys():
        print('You have chosen a ' + pizzas[str(pizza)])
        time.sleep(2)
        order.setdefault('Pizza', pizzas[str(pizza)])         # pizza select successful
        print('Enter Quantity')
        
        qty = input()
    
    while int(qty) <= 0:

        print('That is not a number')

    qty = int(input('Enter Quantity')

    if int(qty) == 1:                      [b]# THIS LINE GIVES ERROR AND HIGHLIGHTS ':'[/b]
        print('You have ordered ' + str(qty) + ' ' + pizzas[str(pizza)])
        time.sleep(2)
        order.setdefault('Qty', str(qty))

    elif qty >= 2:
        print('You have ordered ' + str(qty) + ' ' + pizzas[str(pizza)] + 's')
        time.sleep(2)
        order.setdefault('Qty', str(qty))
Reply


Messages In This Thread
python wont recognize indentation - by JWhykes - Jul-06-2018, 10:40 AM
RE: python wont recognize indentation - by buran - Jul-06-2018, 10:40 AM
RE: python wont recognize indentation - by buran - Jul-06-2018, 10:46 AM
RE: python wont recognize indentation - by JWhykes - Jul-06-2018, 10:47 AM
RE: python wont recognize indentation - by buran - Jul-06-2018, 10:51 AM
RE: python wont recognize indentation - by JWhykes - Jul-06-2018, 10:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why wont this path work one way, but will the other way? cubangt 2 779 Sep-01-2023, 04:14 PM
Last Post: cubangt
  python cant recognize PIP siubikYT 2 948 Jul-19-2023, 06:30 PM
Last Post: Lahearle
  Is it possible to make a program recognize how many clicks it has had on the monitor? jao 0 1,245 Feb-25-2022, 06:31 PM
Last Post: jao
  My program won't recognize the filename. braingoblins 1 1,237 Jan-07-2022, 06:18 PM
Last Post: deanhystad
Star NameError – function doesn't recognize imported modules Sir 4 3,847 Dec-01-2020, 06:36 AM
Last Post: Sir
Bug Python Shell 3.9.0 - Issue with indentation Earis 17 7,209 Oct-31-2020, 07:00 AM
Last Post: Earis
  Player object wont recognize collision with other objects. Jan_97 3 2,871 Dec-22-2019, 04:08 PM
Last Post: joe_momma
  When I import a Module it wont run PyNovice 17 6,872 Oct-26-2019, 11:14 AM
Last Post: PyNovice
  How to recognize space or enter as one-character input? Mark17 5 5,962 Oct-17-2019, 08:19 PM
Last Post: jefsummers
  Pynput doesn't recognize shift button and special characters VirtualDreamer 0 3,156 Jul-17-2019, 11:55 AM
Last Post: VirtualDreamer

Forum Jump:

User Panel Messages

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