Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Type error!
#1
Hello!

I've been working on this program and I don't know why, but there seems to be a problem with it...

txt = "Prob05.in.txt"
msg = open(txt, "r")
msg = msg.read()
h = msg.split("\n")
h=int
g = float
first = True
unSentence = 1
countSentence = 1
while(countSentence <= h[0]):
      while (unSentence <= g[0]):
          Sentence = '\n'
          seq = input (Sentence.format (unSentence))
          print((g[i] - min(lst))/(max(lst) - min(lst))*255)
          unSentence += 1
      countSentence += 1
My file input is:

2
5
0.0
25.0
50.0
75.0
100.0
6
12.3
-67.1
122.8
428.4
-15.9
221.0


But when I try to run the program, there is an error:

Traceback (most recent call last):
File "C:/Users/admin/Desktop/Collège Sainte Marcelline Prog (8)/Problème 05.py", line 10, in <module>
while(countSentence <= h[0]):
TypeError: 'type' object is not subscriptable

Anyone has got an idea?
Reply


Messages In This Thread
Python Type error! - by SamAnw - Feb-14-2020, 01:41 PM
RE: Python Type error! - by buran - Feb-14-2020, 02:13 PM
RE: Python Type error! - by SamAnw - Feb-14-2020, 02:27 PM
RE: Python Type error! - by stullis - Feb-14-2020, 03:45 PM
RE: Python Type error! - by buran - Feb-14-2020, 03:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Wrong type error rowan_bradley 6 1,224 Aug-07-2023, 10:44 AM
Last Post: rowan_bradley
  Type Error: Unsupported Operand jhancock 2 1,185 Jul-22-2023, 11:33 PM
Last Post: jhancock
  Python Anytree - Is not of type 'NodeMixin' error georgebijum 3 2,093 May-05-2022, 01:43 PM
Last Post: Gribouillis
  Incorrect Type Error milkycow 4 2,910 Jun-25-2021, 06:04 AM
Last Post: milkycow
Star Type Error: 'in' object is not callable nman52 3 3,406 May-01-2021, 11:03 PM
Last Post: nman52
  Error : "can't multiply sequence by non-int of type 'float' " Ala 3 3,086 Apr-13-2021, 10:33 AM
Last Post: deanhystad
  Type Error in Python MarcusB 3 2,568 Mar-30-2021, 06:34 PM
Last Post: buran
  unsupported operand type(s) for /: 'str' and 'int' Error for boxplot soft 1 3,064 Feb-09-2021, 05:40 PM
Last Post: soft
  Type Error or Value Error? spalisetty06 3 2,394 Jul-21-2020, 04:56 AM
Last Post: deanhystad
  Type error: '>' not supported between instances of 'NoneType' and 'int' spalisetty06 1 10,482 Apr-29-2020, 06:41 AM
Last Post: buran

Forum Jump:

User Panel Messages

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