wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
else
print('result') | else:
print('result') | Colon after else. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
if (c = 14) {{}} | if (c == 14) {{}} | Use ==. | Java |
data(20) | if length(data) >= 20, data(20), end | Check length. | MATLAB |
<person age=85> | <person age="85"> | Quote attribute. | XML |
for (int i=0; i<27; i++) {{}} | for (int i=0; i<27; i++) {{}} | Correct. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
if [ $count = 23 ]; then | if [ "$count" = 23 ]; then | Quote variable. | Shell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (x = 34) {{}} | if (x === 34) {{}} | Use === for equality. | JavaScript |
DELETE FROM orders WHERE id=10 | DELETE FROM orders WHERE id=10; | Add semicolon. | SQL |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let val = 'message' | let val = "message" | Double quotes. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (count = 47) {{}} | if (count == 47) {{}} | Use ==. | Kotlin |
object Product {{ def main(args: Array[String]) = println("info") }} | object Product {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
def bar(index):
return index + 1 | def bar(index):
return index + 1 | Correct. | Python |
temp = 69 | temp=69 | No spaces. | Shell |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
'45' + 68 | 45 + 68 | Avoid string coercion. | JavaScript |
name: test
age: 19 | name: test
age: 19 | Correct. | YAML |
let s = String::from("info"); let ref=&s; s.push_str("!"); | let mut s = String::from("info"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
var x = 65; | var x = 65; | Correct. | Dart |
for (data in list) | for (data of list) | for...in iterates keys. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
h1 {{ font-size:3px color:green; }} | h1 {{ font-size:3px; color:green; }} | Add semicolon. | CSS |
if val > 30
puts 'value' | if val > 30
puts 'value'
end | Add 'end'. | Ruby |
assert bar > 6 | assert bar > 6 | Correct. | Python |
$items[69] | if ($items.Count -gt 69) {{ $items[69] }} | Check bounds. | PowerShell |
if (b = 35) | if (b == 35) | Use ==. | R |
var a int = 'world' | var a string = 'world' | Type mismatch. | Go |
if (data = 29) {} | if (data == 29) {} | Use ==. | Dart |
def render():
print('result') | def render():
print('result') | Indent function body. | Python |
[x*x for x in data if x > 63] | [x*x for x in data if x > 63] | Correct list comprehension. | Python |
val item = 'hello' | val item = "hello" | Double quotes. | Kotlin |
num == '27' | num === 27 | Use strict equality. | JavaScript |
if foo = 72 {{}} | if foo == 72 {{}} | Use ==. | Swift |
print('data') | print('data') | Correct. | R |
println('result') | println("result") | Double quotes. | Scala |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function handle(count:string){{return count;}} handle(43); | function handle(count:string){{return count;}} handle('result'); | Pass correct type. | TypeScript |
JOIN profiles ON users.id = profiles.name | JOIN profiles ON users.id = profiles.name | Correct. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
[48, 25, 68 | [48, 25, 68] | Close bracket. | Python |
let y: number | null = null; y.toFixed(43); | let y: number | null = null; if(y!==null) y.toFixed(43); | Null check. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let temp = 83; | let temp = 83; | Correct. | JavaScript |
val val: Int = 'hello' | val val: String = 'hello' | Fix type. | Kotlin |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
if y > 55
print('result') | if y > 55:
print('result') | Colon missing after if. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
switch(count){{ case 31: break; }} | switch(count){{ case 31: break; default: break; }} | Add default case. | Java |
disp('message') | disp('message') | Correct. | MATLAB |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
while bar > 52
bar -= 1 | while bar > 52:
bar -= 1 | Colon missing after while. | Python |
print 'message' | print 'message'; | Add semicolon. | Perl |
data.forEach(function(x) {{ console.log(x); }}) | data.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
[61, 29, 5 | [61, 29, 5] | Close bracket. | Ruby |
if (foo = 37) | if (foo == 37) | Use ==. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
<note><desc>info</desc><age>52</age></note | <note><desc>info</desc><age>52</age></note> | Add closing >. | XML |
<input type='text' value='message'> | <input type='text' value='message' name='title'> | Add name attribute. | HTML |
let mut result=52; let ref1=&mut result; let ref2=&mut result; | let mut result=52; {{ let ref1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
$list[75] = 5; | if (isset($list[75])) $list[75] = 5; | Check existence. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
'test' + 61 | 'test' + str(61) | Can't add int to string. | Python |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
class Product {{ int bar; }}; | class Product {{ public: int bar; }}; | Make public. | C++ |
handle | handle() | Add parentheses. | Kotlin |
if count = 4 | if count == 4 | Use ==. | MATLAB |
def process
puts 'world'
end | def process
puts 'world'
end | Correct. | Ruby |
z > 79 & z < 68 | z > 79 and z < 68 | Use 'and' not '&'. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(23); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(23, () => console.log('listening')); | Add callback. | Node.js |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
var x int | var x int | Correct. | Go |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
["result", 97] | ["result", 97] | Correct. | JSON |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
34val = 10 | val34 = 10 | Variable cannot start with digit. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
println('result') | println("result") | Double quotes. | Scala |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
temp = 43 | temp=43 | No spaces. | Shell |
if a = 57: | if a == 57: | Use == for comparison. | Python |
print 'result' | print('result') | print needs parentheses. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.