Skip to main content

Thread: Python Syntax Help!


code:
def parse_actor_data(actor_data):     ##creating list of words relevant lines open text file. goes through first fourteen lines , stops line of 77 hashes , stores other lines     actor_file = actor_data     line_number = 0     list_of_lines = []     end_loop = true     while end_loop:         if line_number < 14:             line_number += 1         elif line.startswith("-----------------------------------------------------------------------------"):             end_loop = false         else:             list_of_lines.append(line.split()     ##abcabc     line_number = 0     final_dictionary = {}     last_actor = ""     while line_number < len(list_of_lines):         movie_name = ""         index_of_line = line_number         words_in_previous_line = list_of_lines[line_number - 1].split()         words_in_this_line = list_of_lines[line_number].split()         ##getting actor name, if line has it, analyzing if there part of line comma         if(line_number == 0 or (len(words_in_previous_line) == 0)):             index_of_comma = find_index_with_string(words_in_this_line, ",")             actor_lastname = words_in_this_line[index_of_comma].strip(",")             index_1 = index_of_comma - 1             while index_1 >= 0:                 actor_lastname = words_in_this_line[index_1] + " " + actor_lastname                 index_1 -= 1             actor_firstname = words_in_this_line[index_of_comma + 1]             actor_name = actor_firstname + " " + actor_lastname             last_actor = actor_name             final_dictionary[actor_name] = []             ##adding in movie             index_of_bracket = find_index_with_string(words_in_this_line, ")")             index_1 = index_of_comma + 2             while index_1 <= index_of_bracket:                 movie_name = movie_name + " " + words_in_this_line[index_1]                 index_1 += 1             final_dictionary[last_actor].append(movie_name)             ##if line not contain actor             else:                   index_of_bracket = find_index_with_string(words_in_this_line, ")")             index_1 = 0             while index_1 <= index_of_bracket:                 movie_name = movie_name + " " + words_in_this_line[index_1]                 index_1 += 1             final_dictionary[last_actor].append(movie_name)          line_number += 1     return final_dictionary
i syntax error after ##abcabc comment - have no idea why. don't think i've done wrong in terms of program logic - thought might reusing variable "line_number" apparently that's okay.

ideas guys? thanks!

can put code in code tags? python without whitespace pretty indecipherable.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Python Syntax Help!


Ubuntu

Comments

Popular posts from this blog

Falang and too many redirects - Joomla! Forum - community, help and support

Infinite loop detected in JErrorInfinite loop detected in JError - Joomla! Forum - community, help and support

logged out from joomla! - Joomla! Forum - community, help and support