post: Hello! So I'm trying to do HW3, and I am having some trouble running my program in the terminal. When I did it gave me completely different input than i was getting in the console: me@me-virtual-machine ~/System/release/hw/3 $ python2.5 hw3.py 0 8 24 48 80 the last value of x was 9 ---------- 0 words 0 characters 0 lines Does anyone know why this might be?
from: Paul Resnick
comment: Can you post screenshots of it running in both places?
from: Emily K Smalls
comment: I was able to fix the mistake!
from: Emily K Smalls
post: Also...on #5 of part II, the replace question, I'm getting an error: I wrote.. hello = lst.replace('5','five') print hello but it gives me an AttributeError: 'list' object has no attribute 'replace'? I also cannot run lst.find without getting an error?
from: Noah James Hermann
comment: replace only works with strings, so make list into a string with str() function. then you can replace it.
from: Emily K Smalls
comment: Thank you!
from: Lance Cummins
comment: You can also directly change that element in the list with something like lst[2] = 'five'
from: Noah James Hermann
comment: thats probably a better method
from: Paul Resnick
comment: Noah is right that replace only works on strings and Lance is right that you can do assignment to list elements. (And thanks, Lance, for making her think instead of just giving her the answer. 2 is just a sample list index there, not the correct one.)
from: Paul Resnick
comment: Suggestion for posting requests about errors in the future: post the error message. In this case, the error message is: Traceback (most recent call last): File "/home/me/System/release/hw/3/hw3.py", line 12, in <module> hello = lst.replace('5','five') AttributeError: 'list' object has no attribute 'replace' This error message actually tells you which line has a problem, and why: replace doesn't work on lists!
from: Jaeyoon Yoo
post: Hi guys I am doing hw3 part II #3 and my code is: for loop in s: print s.split() But I cannot get the same result from the screenshot of hw3 ... what did I do wrong?
from: Paul Resnick
comment: Please check out slides 3 and 4 from Tuesday 1/17 lecture. As you've written it, in the first line you have used loop as the varname. So the second line (if you indent it) will execute once for each character in s, each time with the variable loop bound to a different character from s. Each time it will split s and print out the whole list. Try stepping through it in the debugger to see. With that explanation of what your current code is doing, can you see a way to do what you're trying to do? (Hint: you don't want to iterate through the characters in s; you want to iterate through the items in the list produced by splitting s.)
from: Lauren Fisher
post: okay, I feel like all my questions are really dumb on here, so i apologize everyone. but i have a dell what do i get? there's the player which i think i have but then there are the 3 different workstations. will someone please help me :)
from: Paul Resnick
comment: If you have a Dell, you're running the Windows OS. If you are using VWMware player, you don't need to do anything, because it's already a free forever license for everyone. If you are using VMWare desktop, then you should follow a download process but stop before downloading and just copy the serial number, like what Joe Lucas described in his instructions for Fusion for the Mac.
from: Joe Lucas
post: I got the the VMware license working and Prof. Resnick requested I post what it looks like. I followed the link in the email, signed up, bought VMware fusion, got to the screen on the right, and copied and pasted the number into the window on the left (under VMware Fusion> Buy Now or Enter License...). As you can see my evaluation period is now 410 days instead of 30 days.
from: Jen Eisenberg
comment: thank you - that was very helpful!!
from: Jenny Kim
post: For VMWare Fusion, I just got access to a license but I was wondering if I should re-download it or just type the serial number in. Thanks!
from: Paul Resnick
comment: Looks like just typing pasting in the serial number works. See Joe Lucas' screenshot.
from: Jenny Kim
comment: oh, i didn't see that thank you!
from: Paul Resnick
comment: Actually, he posted it after your original post!
from: Jackie Cohen
post: As Chris pointed out below: in Part II and Part III of HW3, you should look at the instructions in hw3.py, not hw2.
from: Chris Paul
post: For Part II and Part III of homework 3, I am guessing it is the instructions in hw3.py?