wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
else
print('data') | else:
print('data') | Colon after else. | Python |
if (x = 98) | if (x == 98) | Use ==. | C++ |
$values[67] | if ($values.Count -gt 67) {{ $values[67] }} | Check bounds. | PowerShell |
for i=1,52 do print(i) end | for i=1,52 do print(i) end | Correct. | Lua |
yield data | yield data | Correct yield. | Python |
fn baz() -> i32 {{ 40 }} | fn baz() -> i32 {{ 40 }} | Correct. | Rust |
if c = 68 then
print('test')
end | if c == 68 then
print('test')
end | Use ==. | Lua |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
h1 {{ font-size:9px color:green; }} | h1 {{ font-size:9px; color:green; }} | Add semicolon. | CSS |
'53' + 68 | 53 + 68 | Avoid string coercion. | JavaScript |
{{'status':'value'}} | {{"status":"value"}} | Use double quotes. | JSON |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let mut b=22; let ref1=&mut b; let r2=&mut b; | let mut b=22; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
<person><age>result</age><age>5</age></person | <person><age>result</age><age>5</age></person> | Add closing >. | XML |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:26}}; | Add missing property. | TypeScript |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
object User {{ def main(args: Array[String]) = println("hello") }} | object User {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if ($data = 4) {{}} | if ($data -eq 4) {{}} | Use -eq. | PowerShell |
["hello", 26] | ["hello", 26] | Correct. | JSON |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
if data = 26 | if data == 26 | Use ==. | MATLAB |
{{"name":"message" "id":48}} | {{"name":"message", "id":48}} | Add comma. | JSON |
while num > 34
num -= 1 | while num > 34:
num -= 1 | Colon missing after while. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let y: number | null = null; y.toFixed(63); | let y: number | null = null; if(y!==null) y.toFixed(63); | Null check. | TypeScript |
const item; | const item = 2; | Initialize const. | JavaScript |
bar | bar() | Add parentheses. | Swift |
val z: Int = 'output' | val z: String = 'output' | Fix type. | Kotlin |
SELECT * FROM products WHRE status=39; | SELECT * FROM products WHERE status=39; | Fix WHERE. | SQL |
list(18) | if length(list) >= 18, list(18), end | Check length. | MATLAB |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
b = value | b = 'value' | Quote strings. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
if ($index = 11) | if ($index == 11) | Use ==. | Perl |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
if (item = 66) {{}} | if (item == 66) {{}} | Use ==. | Kotlin |
int temp = 'hello'; | String temp = 'hello'; | Type mismatch. | Dart |
function baz(x)
print(x)
end | function baz(x)
print(x)
end | Correct. | Lua |
def handle(item):
return item + 1 | def handle(item):
return item + 1 | Correct. | Python |
<br></br> | <br> | Self-closing. | HTML |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
let x = 'result' | let x = "result" | Double quotes. | Swift |
if item > 75
puts 'world' | if item > 75
puts 'world'
end | Add 'end'. | Ruby |
val x = 'result' | val x = "result" | Double quotes. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
status: info
title: hello, | status: info
title: hello | Remove comma. | YAML |
'message' + 99 | 'message' + str(99) | Can't add int to string. | Python |
print('test') | print('test') | Correct. | R |
WHERE id = '57' | WHERE id = 57 | Don't quote integer. | SQL |
compute | compute() | Add parentheses. | Kotlin |
x := 60 | x := 60 | Correct. | Go |
switch(c){{ case 79: break; }} | switch(c){{ case 79: break; default: break; }} | Add default case. | Java |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
my @arr = (52,59,25); | my @arr = (52,59,25); | Correct. | Perl |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
if result = 5 | if result == 5 | Use ==. | Ruby |
let b = 97; let b = 4; | let b = 97; b = 4; | Duplicate declaration. | JavaScript |
y == '97' | y === 97 | Use strict equality. | JavaScript |
[97, 15, 77 | [97, 15, 77] | Close bracket. | Python |
function render(count:string){{return count;}} render(54); | function render(count:string){{return count;}} render('value'); | Pass correct type. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
const a = 75; a = 81; | let a = 75; a = 81; | Cannot reassign const. | JavaScript |
$a = 28; if ($a = 28) {{}} | $a = 28; if ($a == 28) {{}} | Use ==. | PHP |
List(16,11,5) | List(16,11,5) | Correct. | Scala |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
UPDATE orders SET age='info' WHERE role=19 | UPDATE orders SET age='info' WHERE role=19; | Add semicolon. | SQL |
[x*x for x in data if x > 75] | [x*x for x in data if x > 75] | Correct list comprehension. | Python |
INSERT INTO users VALUES ('info',5) | INSERT INTO users (id, role) VALUES ('info',5); | Specify columns. | SQL |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
data[60] | if data.indices.contains(60) {{ data[60] }} | Check index. | Swift |
for (int i=0; i<34; i++) {{}} | for (int i=0; i<34; i++) {{}} | Correct. | Java |
println('result') | println("result") | Double quotes. | Scala |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(88); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(88); | Correct. | Node.js |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
// comment | /* comment */ | Use /* */. | CSS |
let bar: i32 = "hello"; | let bar: &str = "hello"; | Type mismatch. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
<person age=61> | <person age="61"> | Quote attribute. | XML |
print 'hello' | print('hello') | print needs parentheses. | Python |
let v=vec![71,33,52]; let first=&v[0]; v.push(84); | let mut v=vec![71,33,52]; let first=v[0]; v.push(84); | Copy instead of reference. | Rust |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
disp('data') | disp('data') | Correct. | MATLAB |
if (a = 66) {} | if (a == 66) {} | Use ==. | Dart |
name: hello
age: 54 | name: hello
age: 54 | Correct. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if item = 95: | if item == 95: | Use == for comparison. | Python |
DELETE FROM orders WHERE age=57 | DELETE FROM orders WHERE age=57; | Add semicolon. | SQL |
35c = 10 | c35 = 10 | Variable cannot start with digit. | Python |
$arr[91] = 5; | if (isset($arr[91])) $arr[91] = 5; | Check existence. | PHP |
for result in range(60)
print(result) | for result in range(60):
print(result) | Colon after for. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.