Jump to content

SubhanUllah

Member
  • Posts

    132
  • Joined

  • Last visited

Everything posted by SubhanUllah

  1. You have to know the exact property name that is already typed as long e.g. 1L var url1 = UrlFetchApp.fetch('http://www.google.com/'); JSONObject jsonObject = new JSONObject(urlFetch(url1)); //at this point we have ALL the json properties wrapped in a JSONObject called data1 long height = jsonObject.getLong("longValue"); //longValue has to be one of the properties in
  2. However, the steps are basically the same no matter what theme you're using. Step 1: Create a new product template. ... Step 2: Add the code for the form fields you want to use.Step 3: Customize the Cart page to show your custom product options. ... Step 4: Customize order confirmation emails. ... Step 5: Test it out
  3. String prefix=”prefix”; String suffix=”suffix”; StringBuilder str = new StringBuilder(prefix); str.append(suffix); // print string System.out.println("String = " + str.toString());
  4. thelist = [1, "A", 2, "B"] #Printing the length print(len(thelist)) #OUTPUT 4 Although it will be awkward with a very long list, of course, as you can see, you can always still get the same result doing something crazy like… print(len([1, "A", 2, "B"] #OUTPUT 4
  5. thelist = [1, 2, 3, 4] #Inverse of list order. print(thelist[::-1]) #OUTPUT [4, 3, 2, 1] #Inverse of list items. from fractions import Fraction for i in thelist: print(Fraction(1, i)) #OUTPUT 1 1/2 1/3 1/4
  6. The individual letters would all have to be strings if that string “Hello” were to be pieced out into what would be now be stored as a list [“H”, “e”, “l”, “l”, “o”], and no longer as a string. Because to begin with, your [H, e, l, l, o] wouldn't be recognised by Python. Let's check the type; it will produce an error… print(type([H, e, l, l, o])) #OUTPUT (Error) NameError: name 'H' is not defined If those letters were say numbers or booleans, then they'd be recognised. E.g. [1, 2, 3, 4, 5] So from your string “Hello”, what you could do is to piece it out into a list with a list() casting… thestring = "Hello" thelist = list(thestring) print(thelist) #OUTPUT ['H', 'e', 'l', 'l', 'o'] If you want your string back, as in getting back a string form from thelist, that'd be yet another story, such as using the .join()… thelist = ['H', 'e', 'l', 'l', 'o'] thestringback = "".join(thelist) print(thestringback) #OUTPUT Hello print(type(thestringback)) <class 'str'>
  7. l=[1,2,3,4,5,2,3,4,7,9,5] # janky list with open(filename) as file: l = file.readlines() l= [l.rstrip() for line in lines] # only if you want strip out wihtespaces l1=[] # final list without dupes for i in l: if i not in l1: l1.append(i) else: print(i,end=' ')
×
×
  • Create New...