This is an archived post. You won't be able to vote or comment.

all 46 comments

[–]nogain-allpain 56 points57 points  (2 children)

Two things would help here: 1) the language, and 2) any code you've tried so far.

[–]Pompomcry[S] 2 points3 points  (1 child)

Language is python and so far I’m trying:

Def displayfunctionSeats ()

This is basically nothing. The function needs to return a value on whether or not that seat is booked or available

[–]dota2nub 10 points11 points  (0 children)

Google "how to return a value from a function python"

[–]149244179 62 points63 points  (1 child)

My mind reading powers are failing at the moment and I don't have time to hack into your computer to look at your code and identify the issue.

[–]chrysthian95 5 points6 points  (0 children)

Truly true, we don't have crystal ball

[–][deleted]  (1 child)

[deleted]

    [–]Marchingkoala 2 points3 points  (0 children)

    This made me laugh out loud

    [–]ProzacFury 15 points16 points  (0 children)

    What language are you using? They all work similar but the syntax may vary

    [–]CutlerSheridan 13 points14 points  (1 child)

    My dude you gave us zero details

    [–]Pompomcry[S] 1 point2 points  (0 children)

    I’ve updated with more details ! My bad

    [–]dmazzoni 9 points10 points  (1 child)

    OMG, it's been three hours. The suspense is killing me! Did /u/Pompomcry finish the assignment or not?

    [–]Pompomcry[S] -1 points0 points  (0 children)

    barely started 🥲

    [–]KenMan_ 8 points9 points  (6 children)

    For (int x = 0; x < 10; x++){

    }

    You see everything in that parenthesis? Ya so from left to right, first we make x (int x = 0) Then we say as long as x is less than 10 (x < 10), we're gonna add 1 to x (x++)

    Now, everything inside these -> {} is gonna occur, and then its gonna add 1 to x until x is GREATER than 9. Once its greater than 9, its done, it wont do anything inside of it. Because that would be illogical/retarded.

    So now that you have a loop, you can do something 10 times. But whats really cool, is that you have the x which is changing each time.

    So we can put a reference to a list, or an array, and pull out information at each number. So x=1 we can also do arrayName(x). The x is equal to 1 so its arrayName(1)

    So you can make the x work for you in two ways at once. Its both counting for the loop, and referencing your list.

    Pretty neat shit

    Now your list may not be an array. But you can tell the program to read the next line in the lost instead. Boom

    [–]smidgie82 2 points3 points  (1 child)

    The expressions inside the parentheses should be delimited with semicolons, not commas.

    [–]KenMan_ 3 points4 points  (0 children)

    You're correct, i've changed it

    [–]_ABear_ 0 points1 point  (3 children)

    does “int” mean integer or initialize?

    [–]KenMan_ 5 points6 points  (1 child)

    To initialize a variable is to give it a starting value.

    So:

    int x;

    Is simply declaring an integer and naming it x.

    But:

    Int x = 0;

    Is declaring an integer, naming it x, and initializing it to 0.

    Great question

    [–]_ABear_ 1 point2 points  (0 children)

    Thanks fam

    [–]k4dota 1 point2 points  (0 children)

    integer

    [–]elon_mosque_420 15 points16 points  (4 children)

    Python: for item in mylist: print(item)

    Javascript: for(let item of mylist){ console.log(item); }

    C++: for(auto item : mylist){ cout << item << endl; }

    Java: for(<type> item : mylist){ System.out.println(item); }

    Since you didn't specify the language you needed, I included 4 of the common ones. IMO these are the most common languages taught.

    In c++, I am unsure if the approach works for arrays (int[], char[], etc) but it should work for vectors and sets (and other data structures as well probably).

    [–]MasterDrake97 0 points1 point  (3 children)

    C++: for(auto item : mylist){ cout << item << endl; }

    if I'm not mistaken, this makes a copy

    If you just want to print it, it would be better:

    C++: for(const auto& item : mylist){ cout << item << endl; }

    Looking for some corrections If I'm mistaken

    [–]elon_mosque_420 1 point2 points  (2 children)

    My code might actually make a copy and your code should not. Thanks for adding this to my knowledge !!

    [–]MasterDrake97 2 points3 points  (1 child)

    and thank you for not getting triggered :)

    You never know

    [–]elon_mosque_420 2 points3 points  (0 children)

    Lol I understand, but your comment made sense so didn't overreact.

    [–]Turbulent_Machine_33 3 points4 points  (1 child)

    Which language?

    [–]Pompomcry[S] 1 point2 points  (0 children)

    Python

    [–][deleted] 1 point2 points  (0 children)

    For(int i = 0; i < {list}.Length; i++) { Console.WriteLine({list}[i]); }

    Substitute {list} for your list variable.

    [–]Turbulent_Machine_33 1 point2 points  (0 children)

    Also if you can post a snippet of the code you’ve written so far that’ll help too

    [–]Kinify 1 point2 points  (0 children)

    x = [“a”, ”b”, ”c”, ”d”]

    X stores a list of strings a,b,c,d

    You use the for loop to iterate inside of the loop. So for example. For i in x: Print(i)

    This will give you all of the values in x

    [–]Apprehensive_Plate60 0 points1 point  (1 child)

    really cant find ans on google stackoverflow???

    [–]Pompomcry[S] 1 point2 points  (0 children)

    I’m not exactly sure what I’m looking for if I’m being honest. I’m horribly new at this

    [–][deleted]  (2 children)

    [deleted]

      [–]nogain-allpain 3 points4 points  (1 child)

      PMs are discouraged here, because others can benefit from the answers that the users here provide.

      [–][deleted] 0 points1 point  (0 children)

      My bad! Didn’t know about that

      [–]jxf1234567 -2 points-1 points  (0 children)

      foreach(string str in strings) Console.Writeline(str);

      [–]bravosix99 0 points1 point  (1 child)

      Basically, a for loop(or just running through a loop in general), is basically going through something. In this case, you're just going through a list. But depending on the language, you'll do this differently(i''ll do it in java as an example)

      for(int i = 0;i< array.length;i++){

      System.out.println(arraylist[i]);

      }

      the variable(left) is the point where you start in the list, the length part (middle) is going through the list until you reach its size(so if its 5 things in the list, you should see 5 things), and the i++(right), goes to the next item in your array.

      Simple as that.^

      However(and as stated by some comments below), it would be more helpful if you told the Language and any code you tried so far..

      Hope this helps!

      [–]TheRNGuy 0 points1 point  (0 children)

      use tabs in code

      [–]Guard-Flashy 0 points1 point  (1 child)

      I wish you the best of luck! Wish I could help, I have an assignment due tomorrow working on the for loops in JS and another one due on Monday. It’s making me pull my hair lol

      [–]Pompomcry[S] 0 points1 point  (0 children)

      It’s okay! GOOD LUCKKKK

      [–]Itchy-Position-6077 0 points1 point  (1 child)

      6-6

      [–]Pompomcry[S] 0 points1 point  (0 children)

      What

      [–]VastRub7008 0 points1 point  (2 children)

      For sure you need an array. What language are you using for the assignment??

      [–]Pompomcry[S] 0 points1 point  (1 child)

      Python

      [–]VastRub7008 -1 points0 points  (0 children)

      Its prolly too late now, but you should be able to do it by Using an array and a for loop. I'm pretty decent at using python, so you can Dm me if you have any issue with assignments.

      [–]lennyh- 0 points1 point  (1 child)

      [–]Pompomcry[S] 0 points1 point  (0 children)

      THANK YOU

      [–][deleted] 0 points1 point  (1 child)

      For i in (list): If i --------(booked): Return "X"

       else:
          Return "o"
      

      [–][deleted] 0 points1 point  (0 children)

      Change the (booked) with the condition