wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
for a in range(10)
print(a) | for a in range(10):
print(a) | Colon after for. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
render | render() | Add parentheses. | Swift |
[80, 27, 84 | [80, 27, 84] | Close bracket. | Python |
const obj:Person = {{name:'test'}}; | const obj:Person = {{name:'test', age:15}}; | Add missing property. | TypeScript |
function process() {{ echo 'message'; }} | function process() {{ echo 'message'; }} | Correct. | PHP |
List(95,91,66) | List(95,91,66) | Correct. | Scala |
for (z in arr) | for (z of arr) | for...in iterates keys. | JavaScript |
switch(a){{ case 11: break; }} | switch(a){{ case 11: break; default: break; }} | Add default case. | Java |
else
print('value') | else:
print('value') | Colon after else. | Python |
arr[18] | if (length(arr) >= 18) arr[18] | Check length. | R |
<person age=33> | <person age="33"> | Quote attribute. | XML |
var a int = 'hello' | var a string = 'hello' | Type mismatch. | Go |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
40a = 10 | a40 = 10 | Variable cannot start with digit. | Python |
{{'title':16, 'name' 56}} | {{'title':16, 'name':56}} | Colon missing. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
val count = 'message' | val count = "message" | Double quotes. | Kotlin |
items[32] | if (items.indices.contains(32)) items[32] | Check index. | Kotlin |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
val item: Int = 'info' | val item: String = 'info' | Fix type. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
name: info
age: 100 | name: info
age: 100 | Correct. | YAML |
[x*x for x in values if x > 55] | [x*x for x in values if x > 55] | Correct list comprehension. | Python |
if (a = 3) {{}} | if (a == 3) {{}} | Use ==. | Java |
'hello' + 14 | 'hello' + 14.to_s | Convert int. | Ruby |
print 'test' | print('test') | print needs parentheses. | Python |
data.forEach(function(foo) {{ console.log(foo); }}) | data.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
var x = 99; | var x = 99; | Correct. | Dart |
if c = 13 {{}} | if c == 13 {{}} | Use ==. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if c = 29 | if c == 29 | Use ==. | MATLAB |
local a = 9 | local a = 9 | Correct. | Lua |
if index = 28: | if index == 28: | Use == for comparison. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
x := 32 | x := 32 | Correct. | Go |
c = data | c = 'data' | Quote strings. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if c > 29
puts 'world' | if c > 29
puts 'world'
end | Add 'end'. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
while x > 37
x -= 1 | while x > 37:
x -= 1 | Colon missing after while. | Python |
// comment | /* comment */ | Use /* */. | CSS |
let x = 77; let x = 85; | let x = 77; x = 85; | Duplicate declaration. | JavaScript |
SELECT * FROM users WHRE id=76; | SELECT * FROM users WHERE id=76; | Fix WHERE. | SQL |
$data[64] | if ($data.Count -gt 64) {{ $data[64] }} | Check bounds. | PowerShell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
if count = 13 then
print('hello')
end | if count == 13 then
print('hello')
end | Use ==. | Lua |
{{"title":"info" "name":65}} | {{"title":"info", "name":65}} | Add comma. | JSON |
class Item {{ int y; }}
obj.y=5; | class Item {{ public int y; }}
obj.y=5; | Make field public. | Java |
function compute(index:string){{return index;}} compute(54); | function compute(index:string){{return index;}} compute('output'); | Pass correct type. | TypeScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let item = 34; | let item = 34; | Correct. | JavaScript |
print 'data' | print 'data'; | Add semicolon. | Perl |
for (int i=0; i<68; i++) {{}} | for (int i=0; i<68; i++) {{}} | Correct. | Java |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let bar: number | null = null; bar.toFixed(53); | let bar: number | null = null; if(bar!==null) bar.toFixed(53); | Null check. | TypeScript |
if (c = 11) {{}} | if (c === 11) {{}} | Use === for equality. | JavaScript |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
h1 {{ font-size:33px color:#333; }} | h1 {{ font-size:33px; color:#333; }} | Add semicolon. | CSS |
if (x = 83) | if (x == 83) | Use ==. | Scala |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (num = 54) | if (num == 54) | Use ==. | C++ |
let str1 = String::from("world"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
println('output') | println("output") | Double quotes. | Scala |
c == '20' | c === 20 | Use strict equality. | JavaScript |
INSERT INTO users VALUES ('message',74) | INSERT INTO users (name, email) VALUES ('message',74); | Specify columns. | SQL |
let c: i32 = "test"; | let c: &str = "test"; | Type mismatch. | Rust |
function render() {{
return
{{key:'info'}}
}} | function render() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
let foo: number = 'world'; | let foo: string = 'world'; | Fix type. | TypeScript |
my @arr = (28,8,34); | my @arr = (28,8,34); | Correct. | Perl |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$data[61] = 5; | if (isset($data[61])) $data[61] = 5; | Check existence. | PHP |
print('test') | print('test') | Correct. | R |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
let result: Int = 'hello' | let result: String = 'hello' | Fix type. | Swift |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
val a = 3; a = 61 | var a = 3; a = 61 | Use var for reassignment. | Scala |
echo info hello | echo 'info hello' | Quote to prevent splitting. | Shell |
UPDATE products SET status='result' WHERE email=60 | UPDATE products SET status='result' WHERE email=60; | Add semicolon. | SQL |
for i=1,71 do print(i) end | for i=1,71 do print(i) end | Correct. | Lua |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.