I have a list of street names(street_na mes) and another list of street names and speeds(streets_ speeds).
street_names is shorter than streets_speeds.
I want to compare the values of street_names to streets_speeds and if the value is in streets_speeds, then it will return the name of the street and speed into a list.
When I run this, it returns nothing.
I'd like it to return the name of the street with the associated speed from the streetSpeeds list.
Thanks for your help.
Miguel
street_names is shorter than streets_speeds.
I want to compare the values of street_names to streets_speeds and if the value is in streets_speeds, then it will return the name of the street and speed into a list.
Code:
streetNames=open('street.txt','r')
streetSpeeds=open('street_speed.txt','r')
newStreetList=[]
for street in streetNames:
if street in (streetSpeeds):
newStreetList.append(street)
print newStreetList
filename = "Street_with_Speed.txt"
f = open(filename, 'w')
f.write("".join(newStreetList))
f.close()
I'd like it to return the name of the street with the associated speed from the streetSpeeds list.
Thanks for your help.
Miguel
Comment