[Solved] Compare occurrences between str in two lists [closed]

Here is how you can use a nested for-loop with formmatted strings: list1 = [“ilovepython”,”ilovec#”] list2 = [“love”,”python”] for i in list1: # For every string in list11 print(f’in “{i}”:’) # Print the string for j in list2: # For every string in list2 num = i.count(j) # Store the number of occurrences of the … Read more

[Solved] c#, non-prime numbers, array, returning, method [closed]

static void Main(string[] args) { int[] array = new int[] { 1, 2, 3, 4, 5, 6, 7,8,9,10,11,12,13,14 }; List<int> nonprimeNumbers = new List<int>(); int sumofnonprimenumbers = 0; for (int i = 0; i < array.Length; i++) { if (!IsPrime(array[i])) { //Console.WriteLine(array[i]); nonprimeNumbers.Add(array[i]); } } Console.Write(“Non-Prime Numbers:”); for (int i = 0; i < nonprimeNumbers.Count; … Read more

[Solved] problems with scanf and conversion specifiers

These are the very basics of C Programming, and I strongly advise you to get a decent book – The C Programming Language by Dennis Ritchie would be a good start. There are numerous errors in your code. A char can contain only one character, like ‘A’, or ‘a’ or something like that. When you’re … Read more

[Solved] COUNT and GROUP BY doesn’t works as expected [closed]

What exactly you want to count? Only consumed? Or consumed by goal? If the second option, you need group by statment. SELECT count(consumed) as count FROM (some select) alias Or SELECT count(consumed) as count, goal FROM (some select) alias Group by goal solved COUNT and GROUP BY doesn’t works as expected [closed]

[Solved] image gallery display with a main image and smaller images

.gallery {width: 100%;} .gallery a { display: flex; } .gallery img{width: 80%; height: auto;} .image-container { display: flex; flex-direction: column; margin-left: 11px; width: 20%; height: 300px; overflow: scroll; } .image-container img { margin: 11px 0 0;} .image-container img:first-child { margin: 0 0 0;} <div class=”gallery”> <a href=”https://images.pexels.com/photos/417074/pexels-photo-417074.jpeg”> <img class=”card-img-top” src=”https://images.pexels.com/photos/417074/pexels-photo-417074.jpeg” alt=”Fő kép”> <div class=”image-container”> <img … Read more

[Solved] Getting TypeError: ‘int’ object is not subscriptable [closed]

I suspect that’s what you’re looking for: def hourglassSum(): arr = [] for i in range(0,6): arr1=map(int,input().split()) arr.append(list(arr1)) sum=[] for i in range(len(arr)-2): for j in range(min(len(arr[i]), len(arr[i+1]), len(arr[i+2]))-2): sum.append(arr[i][j]+arr[i][j+1]+arr[i][j+2]+arr[i+1][j]+arr[i+2][j]+arr[i+2][j+1]+arr[i+2][j+2]) maxi=max(sum) print(maxi) Two notes: (1) you want to persist each iteration of the first loop, what you were doing was just overwriting your variable with … Read more

[Solved] bit values from 0 to 255 for valid IP address

If you for some reason can’t use imports, i.e. it is a homework to do it without, following is working version of your code: b = str(input()) k = b.split(‘.’) if (len(k)!=4): print(“input length is incorrect”) else: error = False for num in k: if int(num)<0 or int(num)>255: print(‘Error in your IP addr’) error = … Read more

[Solved] how create overlay EditText in Activity [closed]

Wel come to Stackoverflow. Its not Dialog. its Activity as a dialog public class diaActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.test_dialog); } } test_dialog.xml <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:background=”#FFFFFF” android:orientation=”vertical” > <LinearLayout android:layout_width=”match_parent” android:layout_height=”42dp” android:orientation=”horizontal” android:weightSum=”3″ > <Button android:id=”@+id/button1″ android:layout_width=”0dp” android:layout_height=”wrap_content” android:layout_weight=”1″ android:text=”Cancle” /> … Read more

[Solved] Extract a part from URL in Javascript [duplicate]

try with this var url=”http://a.long.url/can/be/here/jquery.min.js?207″; var path = url.split( “https://stackoverflow.com/” ); var stripped = “”; for ( i = 0; i < path.length-1; i++ ) { if(i>0) stripped += “https://stackoverflow.com/”; stripped += path[i]; } alert(stripped) solved Extract a part from URL in Javascript [duplicate]

[Solved] String is empty [closed]

You are getting StringIndexOutOfBoundsException because first thing in your while (number.charAt(0) != ‘0’ || number.length() < 4 || !number.matches(“^[0-9]*”) || number.isEmpty()) condition is number.charAt(0) which can throw exception if string is empty “”. To get rid of this problem move number.isEmpty() before number.charAt(0) != ‘0’. This is to validate a phone number that starts with … Read more

[Solved] App stop working

Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet] 01-19 10:43:19.400: E/AndroidRuntime(1482): at java.lang.Class.getConstructorOrMethod(Class.java:472) You are not providing all of the constructors required for a custom view. Specifically, add this constructor. Read the documentation and tutorials for how to use the attribute set: public JustifiedTextView(Context context, AttributeSet attrs){ super(context, attrs); this.setWebChromeClient(new WebChromeClient() { }); } 2 … Read more