By Mirko Urania


2020-05-22 23:17:39 8 Comments

I'm really sorry I'm such a beginner... At the end I just have a list of 8 TimeCardDayStrip with the same name/position when it'd supposed to be the 8 different names/roles. I don't understand what I'm doing wrong here: thank you very much

'''
class TimeCardDayStrip {
  String name, position;
  DateTime day;

  @override
  String toString(){
    return '{ $this.name, $this.position }';
  }
}

void main() {
  var tcds = TimeCardDayStrip();
  var listOfTcds = [];
  List<String> names, roles;
   names = ["Michael", "Gunnell", "Byrne", "Aspromonte", "Davis", "Adam Jordan", "Mirko"];
  roles = ["Director", "Vice", "President", "1ST", "KEY 2ND", "2ND", "BASECAMP PA", "PA", " PA", "Add'l PA"];

  for (int i = 0; i < names.length; i++) {
    tcds.name = names[i];
    tcds.position = roles[i];
    listOfTcds.add(tcds);
    // checking the list as it creates
    print(listOfTcds[i].name+' is '+listOfTcds[i].position);
  }
  //print the list of card to check
  print('print the list of time card to check');
  for (int x = 0; x < listOfTcds.length; x++){
    print (listOfTcds.elementAt(x).name);
  }
}
'''

Related Questions

Sponsored Content

27 Answered Questions

[SOLVED] How do I check if a list is empty?

  • 2008-09-10 06:20:11
  • Ray
  • 2845436 View
  • 3234 Score
  • 27 Answer
  • Tags:   python list

60 Answered Questions

[SOLVED] How do you split a list into evenly sized chunks?

27 Answered Questions

[SOLVED] How do I concatenate two lists in Python?

20 Answered Questions

[SOLVED] Are static class variables possible in Python?

7 Answered Questions

[SOLVED] How do I get the number of elements in a list?

  • 2009-11-11 00:30:54
  • y2k
  • 3258390 View
  • 1934 Score
  • 7 Answer
  • Tags:   python list

20 Answered Questions

18 Answered Questions

[SOLVED] How to clone or copy a list?

40 Answered Questions

[SOLVED] How to make a flat list out of list of lists?

30 Answered Questions

[SOLVED] Finding the index of an item in a list

  • 2008-10-07 01:39:38
  • Eugene M
  • 3866068 View
  • 3162 Score
  • 30 Answer
  • Tags:   python list indexing

11 Answered Questions

[SOLVED] Getting the last element of a list

  • 2009-05-30 19:28:53
  • Janusz
  • 2102674 View
  • 2058 Score
  • 11 Answer
  • Tags:   python list indexing

Sponsored Content