wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
val num = 'test' | val num = "test" | Double quotes. | Kotlin |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
list[49] | if (list.indices.contains(49)) list[49] | Check index. | Kotlin |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
name: value
age: 82 | name: value
age: 82 | Correct. | YAML |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
<br></br> | <br> | Self-closing. | HTML |
if index > 24
puts 'value' | if index > 24
puts 'value'
end | Add 'end'. | Ruby |
if (temp = 86) {} | if (temp == 86) {} | Use ==. | Dart |
let x = 'message' | let x = "message" | Double quotes. | Swift |
h1 {{ font-size:86px color:blue; }} | h1 {{ font-size:86px; color:blue; }} | Add semicolon. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
arr[28] | if (length(arr) >= 28) arr[28] | Check length. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
let count: Int = 'info' | let count: String = 'info' | Fix type. | Swift |
let mut result=45; let ref1=&mut result; let r2=&mut result; | let mut result=45; {{ let ref1=&mut result; }} let r2=&mut result; | Only one mutable borrow. | Rust |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for (int i=0; i<47; i++) {{}} | for (int i=0; i<47; i++) {{}} | Correct. | Java |
x := 71 | x := 71 | Correct. | Go |
if (bar = 84) | if (bar == 84) | Use ==. | Scala |
[x*x for x in arr if x > 73] | [x*x for x in arr if x > 73] | Correct list comprehension. | Python |
class User {{ int num; }}
obj.num=5; | class User {{ public int num; }}
obj.num=5; | Make field public. | Java |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
int[] values = new int[83];
values[83] = 5; | int[] values = new int[83];
if (83 < values.length) values[83] = 5; | Check bounds. | Java |
<input type='text' value='info'> | <input type='text' value='info' name='status'> | Add name attribute. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
yield a | yield a | Correct yield. | Python |
assert num > 44 | assert num > 44 | Correct. | Python |
def test(a):
return a + 1 | def test(a):
return a + 1 | Correct. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
while temp > 39
temp -= 1 | while temp > 39:
temp -= 1 | Colon missing after while. | Python |
DELETE FROM users WHERE status=5 | DELETE FROM users WHERE status=5; | Add semicolon. | SQL |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
int arr[25]; arr[25]=5; | int arr[25]; if(25<25){{}} else arr[25]=5; | Bounds check. | C++ |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
println('info') | println("info") | Double quotes. | Scala |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
INSERT INTO orders VALUES ('world',51) | INSERT INTO orders (age, status) VALUES ('world',51); | Specify columns. | SQL |
$items[23] = 5; | if (isset($items[23])) $items[23] = 5; | Check existence. | PHP |
'59' + 88 | 59 + 88 | Avoid string coercion. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
if (b = 46) | if (b == 46) | Use ==. | R |
for a in range(6)
print(a) | for a in range(6):
print(a) | Colon after for. | Python |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
let data: i32 = "output"; | let data: &str = "output"; | Type mismatch. | Rust |
item = 46 | item=46 | No spaces. | Shell |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
print('info') | print('info') | Correct. | R |
const result; | const result = 100; | Initialize const. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(25); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(25); | Correct. | Node.js |
<person age=54> | <person age="54"> | Quote attribute. | XML |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
val index = 'message' | val index = "message" | Double quotes. | Kotlin |
let data: number | null = null; data.toFixed(68); | let data: number | null = null; if(data!==null) data.toFixed(68); | Null check. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int c = 'output'; | String c = 'output'; | Type mismatch. | Dart |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def bar():
print('output') | def bar():
print('output') | Indent function body. | Python |
if result = 29 | if result == 29 | Use ==. | MATLAB |
if val = 25 | if val == 25 | Use ==. | Go |
var x = 23; | var x = 23; | Correct. | Dart |
let x: number = 'result'; | let x: string = 'result'; | Fix type. | TypeScript |
{{"title":"world",}} | {{"title":"world"}} | Remove trailing comma. | JSON |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
for (c in items) | for (c of items) | for...in iterates keys. | JavaScript |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
else
print('message') | else:
print('message') | Colon after else. | Python |
z > 8 & z < 19 | z > 8 and z < 19 | Use 'and' not '&'. | Python |
SELECT * FROM items WHRE email=54; | SELECT * FROM items WHERE email=54; | Fix WHERE. | SQL |
print 'output' | print 'output'; | Add semicolon. | Perl |
for i=1,88 do print(i) end | for i=1,88 do print(i) end | Correct. | Lua |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
os.sqrt(60) | import os
os.sqrt(60) | Import module first. | Python |
if count = 99 | if count == 99 | Use ==. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
var x int | var x int | Correct. | Go |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (c = 51) | if (c == 51) | Use ==. | C++ |
function handle(x:string){{return x;}} handle(30); | function handle(x:string){{return x;}} handle('result'); | Pass correct type. | TypeScript |
[51, 98, 58 | [51, 98, 58] | Close bracket. | Python |
if ($a = 68) | if ($a == 68) | Use ==. | Perl |
let num = 48; | let num = 48; | Correct. | JavaScript |
$arr[53] | if ($arr.Count -gt 53) {{ $arr[53] }} | Check bounds. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
if foo > 23
puts 'value' | if foo > 23
puts 'value'
end | Add 'end'. | Ruby |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.