Python Forum
Unable to execute the for loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to execute the for loop
#1
Hi Guys

I have got a set of table(FruitsTable, B2:E5) from excel and would like to the font color to be red for column B if quantity is > 6500 via using python.
However, I ran into a syntax error after typing the for loop and unable to find out what is the issue. Hence, would appreciate if you guys would assist with the code. Thanks in advance!

A B C D E
1 Fruits 2011 2012 2013 2014
2 Apples 10000 5000 8000 6000
3 Pears 20000 30000 4000 5000
4 Bananas 6000 6500 6700 6000
5 Oranges 500 300 200 700




from openpyxl import Workbook
from openpyxl.styles import *
from openpyxl.worksheet.table import Table, TableStyleInfo
import openpyxl
workbook = openpyxl.load_workbook("C:/Users/HAROLD/Desktop/Python 3/Automate excel data using python/Employees.xlsx")
worksheet = workbook['Table']

style = TableStyleInfo(name = "TableStyleMedium9", showRowStripes = True, showColumnStripes = True)
table.tableStyleInfo = style

font = Font(color = colors.RED, bold = True, italic = Bold)

for cell_number in range (2,6):
	if int(worksheet['B%s' % (cell_number)].value > 6500:
Reply
#2
on line 14 there is missing closing bracket for int function
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to Loop Over Date gdbengo 2 1,268 Jan-09-2022, 05:11 PM
Last Post: menator01
  Unable to execute input(). jahuja73 5 4,373 Feb-18-2021, 07:41 AM
Last Post: bowlofred
  Unable to print stuff from while loop Nick1507 4 2,281 Sep-17-2020, 02:26 PM
Last Post: Nick1507
  Unable to combine print statements in for loop adeana 2 1,954 Jun-12-2020, 05:08 PM
Last Post: adeana
  Unable to use sqlanydb to execute Sybase IQ Stored Procedure FORTITUDE 4 3,739 Sep-15-2018, 05:03 PM
Last Post: FORTITUDE
  For Loop, execute one time for every loop iteration dragan979 2 4,396 Feb-20-2018, 12:02 PM
Last Post: dragan979

Forum Jump:

User Panel Messages

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