wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (y = 63) | if (y == 63) | Use ==. | R |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
val index = 'hello' | val index = "hello" | Double quotes. | Kotlin |
let vec=vec![25,28,100]; let first=&vec[0]; vec.push(57); | let mut vec=vec![25,28,100]; let first=vec[0]; vec.push(57); | Copy instead of reference. | Rust |
{{"title":"hello",}} | {{"title":"hello"}} | Remove trailing comma. | JSON |
List(81,91,32) | List(81,91,32) | Correct. | Scala |
function test() {{ echo 'info'; }} | function test() {{ echo 'info'; }} | Correct. | PHP |
function handle(): void {{ return 48; }} | function handle(): number {{ return 48; }} | Return type mismatch. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let bar: Int = 'data' | let bar: String = 'data' | Fix type. | Swift |
let c = 31; | let c = 31; | Correct. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
for (result in data) | for (result of data) | for...in iterates keys. | JavaScript |
print 'hello' | print('hello') | print needs parentheses. | Python |
var x = 28; | var x = 28; | Correct. | Dart |
let msg = String::from("data"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
items[3] | if items.indices.contains(3) {{ items[3] }} | Check index. | Swift |
sys.sqrt(58) | import sys
sys.sqrt(58) | Import module first. | Python |
<input type='text' value='output'> | <input type='text' value='output' name='id'> | Add name attribute. | HTML |
function compute(c:string){{return c;}} compute(83); | function compute(c:string){{return c;}} compute('hello'); | Pass correct type. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
fn compute() -> i32 {{ 9 }} | fn compute() -> i32 {{ 9 }} | Correct. | Rust |
else
print('info') | else:
print('info') | Colon after else. | Python |
DELETE FROM items WHERE email=8 | DELETE FROM items WHERE email=8; | Add semicolon. | SQL |
[54, 36, 9 | [54, 36, 9] | Close bracket. | Python |
x := 14 | x := 14 | Correct. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
{{'age':'value'}} | {{"age":"value"}} | Use double quotes. | JSON |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
test | test() | Add parentheses. | Swift |
y > 38 & z < 58 | y > 38 and z < 58 | Use 'and' not '&'. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<entry><name>message</name><name>98</name></entry | <entry><name>message</name><name>98</name></entry> | Add closing >. | XML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
test | test() | Add parentheses. | Kotlin |
int val = 'value'; | String val = 'value'; | Type mismatch. | Dart |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for (int i=0; i<33; i++) {{}} | for (int i=0; i<33; i++) {{}} | Correct. | Java |
object User {{ def main(args: Array[String]) = println("output") }} | object User {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
println('message') | println("message") | Double quotes. | Scala |
echo test hello | echo 'test hello' | Quote to prevent splitting. | Shell |
[x*x for x in values if x > 93] | [x*x for x in values if x > 93] | Correct list comprehension. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{"age":"value" "title":52}} | {{"age":"value", "title":52}} | Add comma. | JSON |
String num = 'hello'; | String num = "hello"; | Double quotes. | Java |
'hello' + 78 | 'hello' + 78.to_s | Convert int. | Ruby |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
'value' + 65 | 'value' + str(65) | Can't add int to string. | Python |
function render(data)
print(data)
end | function render(data)
print(data)
end | Correct. | Lua |
WHERE age = '73' | WHERE age = 73 | Don't quote integer. | SQL |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
age: data
title: data, | age: data
title: data | Remove comma. | YAML |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if ($x = 63) {{}} | if ($x -eq 63) {{}} | Use -eq. | PowerShell |
print 'message' | print('message') | print needs parentheses. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$x = 38; if ($x = 38) {{}} | $x = 38; if ($x == 38) {{}} | Use ==. | PHP |
int arr[58]; arr[58]=5; | int arr[58]; if(58<58){{}} else arr[58]=5; | Bounds check. | C++ |
let z: i32 = "info"; | let z: &str = "info"; | Type mismatch. | Rust |
data(38) | if length(data) >= 38, data(38), end | Check length. | MATLAB |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
<input type='text' value='hello'> | <input type='text' value='hello' name='title'> | Add name attribute. | HTML |
print('info') | print('info') | Correct. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let temp: Int = 'world' | let temp: String = 'world' | Fix type. | Swift |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
my @arr = (3,23,3); | my @arr = (3,23,3); | Correct. | Perl |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
["info", 12] | ["info", 12] | Correct. | JSON |
if (a = 38) {{}} | if (a == 38) {{}} | Use ==. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
a == '73' | a === 73 | Use strict equality. | JavaScript |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
if bar = 15 | if bar == 15 | Use ==. | Go |
for (data in values) | for (data of values) | for...in iterates keys. | JavaScript |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
if item = 50 then
print('data')
end | if item == 50 then
print('data')
end | Use ==. | Lua |
$list[76] | if ($list.Count -gt 76) {{ $list[76] }} | Check bounds. | PowerShell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
<person age=87> | <person age="87"> | Quote attribute. | XML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
while x > 55
x -= 1 | while x > 55:
x -= 1 | Colon missing after while. | Python |
items.forEach(function(foo) {{ console.log(foo); }}) | items.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
if (result = 15) {{}} | if (result === 15) {{}} | Use === for equality. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.