Confused on what a challenge is asking?
-
- Posts: 17
- Joined: Mon Jan 26, 2009 10:02 pm
-
- Posts: 60
- Joined: Fri Nov 07, 2008 10:43 am
- Location: Germany
What is a 8411 ???
I don't want any hint or solution, but the challenge name is "Like a 8411" and i have no idea about what a 8411 could be
Found it .... had to think outside the box
I don't want any hint or solution, but the challenge name is "Like a 8411" and i have no idea about what a 8411 could be
Found it .... had to think outside the box
Last edited by cyberwoozle on Wed Apr 08, 2009 8:44 pm, edited 1 time in total.
- Yharaskrik
- Posts: 31
- Joined: Wed Nov 05, 2008 11:44 am
- Location: Germany
Anybody Out There?
I have absolutely no idea what the challenge "Anybody Out There?" is asking for
Feeling desperate about the Valuation Challenge
Hi everyone. I've been trying to debug the following *Python26* code for the challenge Valuation for about 2 days now, without succession:
Am I making the right approach with the "'x'", or should I just store x = 0 at the start and take 'these' off the ones on the main list?
Also, on:
It gives me an error:
Should I instead define the int() and str() already in the list to make it work or does someone have a brighter idea?
I just can't seem to understand how I'm able to fail at something as simple as this. Might be that I'm new to the language anyways but...
Thanks in advance!
Code: Select all
main = [1,2,3,'x','x',4,5,6]
counter = 0
lenght = len(main)
total = 0
while counter < lenght:
if main[counter] == "'x'":
main.remove(counter)
counter = counter - 2
else:
total = total + main[counter]
counter = counter + 1
if counter == lenght:
print total
Also, on:
Code: Select all
else:
total = total + main[counter]
What I do understand of this error is that I cannot add a string to a total sum, but I have no idea for to make it work even with the int() operator/variable. Trying to wrap the line, a part of the line, or even only a word in the line doesn't seem to do the trick. I just can't seem to be able to change a string into int and vice versa.TypeError: unsupported operand type(s) for +: 'int' and 'str'
Should I instead define the int() and str() already in the list to make it work or does someone have a brighter idea?
I just can't seem to understand how I'm able to fail at something as simple as this. Might be that I'm new to the language anyways but...
Thanks in advance!
to print out the total only when the counter is the same as lengTH (omglol typo on teh code) of the original main list - aka when it meets the end of the list.Arkondi wrote:I'm using Python 3.1, but I think the way you are using remove is wrong. I suggest you take a look into the documentation for the correct use of remove.
And why do you use an if-statement at the end?
Try to understand the following interactive python session.
After that review your code again.
After that review your code again.
Code: Select all
Python 2.6.2 (r262:71600, Mar 29 2010, 15:30:01)
[GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = [1,2,3,'x','x',4,5,6]
>>> type(a[0])
<type 'int'>
>>> type(a[3])
<type 'str'>
>>> a.remove(4)
>>> a
[1, 2, 3, 'x', 'x', 5, 6]
>>> del a[3]
>>> a
[1, 2, 3, 'x', 5, 6]
>>> len("'x'")
3
>>> "'x'"[2]
"'"
>>> len(a)
6
>>> a.remove(6)
>>> len(a)
5
>>> b = int('6')
>>> b
6
>>> type(b)
<type 'int'>
>>> c = str(b)
>>> c
'6'
>>> type(c)
<type 'str'>
>>>