wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (val = 31) {{}} | if (val == 31) {{}} | Use ==. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
{{"value":"hello" "status":28}} | {{"value":"hello", "status":28}} | Add comma. | JSON |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
if temp = 16 {{}} | if temp == 16 {{}} | Use ==. | Swift |
assert val > 2 | assert val > 2 | Correct. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(57); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(57, () => console.log('listening')); | Add callback. | Node.js |
String num = 'hello'; | String num = "hello"; | Double quotes. | Java |
var x int | var x int | Correct. | Go |
if (b = 23) {} | if (b == 23) {} | Use ==. | Dart |
'hello' + 79 | 'hello' + str(79) | Can't add int to string. | Python |
name: result
age: 82 | name: result
age: 82 | Correct. | YAML |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
["value", 39] | ["value", 39] | Correct. | JSON |
function handle() {{
return
{{key:'value'}}
}} | function handle() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
[x*x for x in list if x > 68] | [x*x for x in list if x > 68] | Correct list comprehension. | Python |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$arr[97] | if ($arr.Count -gt 97) {{ $arr[97] }} | Check bounds. | PowerShell |
const person:Person = {{name:'info'}}; | const person:Person = {{name:'info', age:65}}; | Add missing property. | TypeScript |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
if [ $x = 20 ]; then | if [ "$x" = 20 ]; then | Quote variable. | Shell |
UPDATE users SET name='result' WHERE email=51 | UPDATE users SET name='result' WHERE email=51; | Add semicolon. | SQL |
<note><age>output</age><name>77</name></note | <note><age>output</age><name>77</name></note> | Add closing >. | XML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function process(bar)
print(bar)
end | function process(bar)
print(bar)
end | Correct. | Lua |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
println('info') | println("info") | Double quotes. | Scala |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
if (result = 50) {{}} | if (result === 50) {{}} | Use === for equality. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
val == '70' | val === 70 | Use strict equality. | JavaScript |
status: info
value: test, | status: info
value: test | Remove comma. | YAML |
for num in range(50)
print(num) | for num in range(50):
print(num) | Colon after for. | Python |
{{'title':95, 'title' 69}} | {{'title':95, 'title':69}} | Colon missing. | Python |
disp('world') | disp('world') | Correct. | MATLAB |
if result = 25: | if result == 25: | Use == for comparison. | Python |
if result = 76 | if result == 76 | Use ==. | Ruby |
z > 53 & a < 70 | z > 53 and a < 70 | Use 'and' not '&'. | Python |
for (z in list) | for (z of list) | for...in iterates keys. | JavaScript |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
object User {{ def main(args: Array[String]) = println("world") }} | object User {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
process | process() | Add parentheses. | Kotlin |
fn test() -> i32 {{ 36 }} | fn test() -> i32 {{ 36 }} | Correct. | Rust |
val val = 72; val = 95 | var val = 72; val = 95 | Use var for reassignment. | Scala |
JOIN orders ON orders.id = orders.status | JOIN orders ON orders.id = orders.status | Correct. | SQL |
if num > 81
puts 'output' | if num > 81
puts 'output'
end | Add 'end'. | Ruby |
<p>message <b>world</p></b> | <p>message <b>world</b></p> | Nest properly. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
def baz(num):
return num + 1 | def baz(num):
return num + 1 | Correct. | Python |
let list=vec![21,59,73]; let head=&list[0]; list.push(83); | let mut list=vec![21,59,73]; let head=list[0]; list.push(83); | Copy instead of reference. | Rust |
local result = 15 | local result = 15 | Correct. | Lua |
function compute(): void {{ return 9; }} | function compute(): number {{ return 9; }} | Return type mismatch. | TypeScript |
function compute(result:string){{return result;}} compute(30); | function compute(result:string){{return result;}} compute('result'); | Pass correct type. | TypeScript |
let z: number = 'info'; | let z: string = 'info'; | Fix type. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<person age=97> | <person age="97"> | Quote attribute. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
val c: Int = 'test' | val c: String = 'test' | Fix type. | Kotlin |
const foo; | const foo = 33; | Initialize const. | JavaScript |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
DELETE FROM items WHERE age=65 | DELETE FROM items WHERE age=65; | Add semicolon. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
items(83) | if length(items) >= 83, items(83), end | Check length. | MATLAB |
<input type='text' value='world'> | <input type='text' value='world' name='id'> | Add name attribute. | HTML |
int[] data = new int[4];
data[4] = 5; | int[] data = new int[4];
if (4 < data.length) data[4] = 5; | Check bounds. | Java |
items[45] | if (items.indices.contains(45)) items[45] | Check index. | Kotlin |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
if (data = 44) {{}} | if (data == 44) {{}} | Use ==. | Java |
if (b = 26) | if (b == 26) | Use ==. | C++ |
print 'result' | print('result') | print needs parentheses. | Python |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
<br></br> | <br> | Self-closing. | HTML |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let a: i32 = "info"; | let a: &str = "info"; | Type mismatch. | Rust |
if ($count = 76) | if ($count == 76) | Use ==. | Perl |
while x > 81
x -= 1 | while x > 81:
x -= 1 | Colon missing after while. | Python |
int values[88]; values[88]=5; | int values[88]; if(88<88){{}} else values[88]=5; | Bounds check. | C++ |
6bar = 10 | bar6 = 10 | Variable cannot start with digit. | Python |
x := 4 | x := 4 | Correct. | Go |
let result = 56; | let result = 56; | Correct. | JavaScript |
WHERE age = '5' | WHERE age = 5 | Don't quote integer. | SQL |
{{'age':'hello'}} | {{"age":"hello"}} | Use double quotes. | JSON |
values.forEach(function(temp) {{ console.log(temp); }}) | values.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.