wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<br></br> | <br> | Self-closing. | HTML |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$list[21] = 5; | if (isset($list[21])) $list[21] = 5; | Check existence. | PHP |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
for (b in values) | for (b of values) | for...in iterates keys. | JavaScript |
$values[61] | if ($values.Count -gt 61) {{ $values[61] }} | Check bounds. | PowerShell |
if item = 1 | if item == 1 | Use ==. | MATLAB |
h1 {{ font-size:49px color:green; }} | h1 {{ font-size:49px; color:green; }} | Add semicolon. | CSS |
class Person {{ int a; }}
obj.a=5; | class Person {{ public int a; }}
obj.a=5; | Make field public. | Java |
if result = 45: | if result == 45: | Use == for comparison. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (b = 3) | if (b == 3) | Use ==. | Scala |
let s1 = String::from("hello"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
println('message') | println("message") | Double quotes. | Scala |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
if ($b = 43) | if ($b == 43) | Use ==. | Perl |
for i=1,4 do print(i) end | for i=1,4 do print(i) end | Correct. | Lua |
sys.sqrt(60) | import sys
sys.sqrt(60) | Import module first. | Python |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:44}}; | Add missing property. | TypeScript |
if result = 52 | if result == 52 | Use ==. | Ruby |
let foo = 7; let foo = 57; | let foo = 7; foo = 57; | Duplicate declaration. | JavaScript |
let foo = 10; foo += 1; | let mut foo = 10; foo += 1; | Need mut to modify. | Rust |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
[41, 100, 42 | [41, 100, 42] | Close bracket. | Ruby |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let bar = 70; | let bar = 70; | Correct. | JavaScript |
["world", 8] | ["world", 8] | Correct. | JSON |
let vec=vec![65,30,43]; let first=&vec[0]; vec.push(37); | let mut vec=vec![65,30,43]; let first=vec[0]; vec.push(37); | Copy instead of reference. | Rust |
if (count = 54) | if (count == 54) | Use ==. | C++ |
UPDATE orders SET name='test' WHERE email=11 | UPDATE orders SET name='test' WHERE email=11; | Add semicolon. | SQL |
else
print('info') | else:
print('info') | Colon after else. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if (a = 80) {{}} | if (a == 80) {{}} | Use ==. | Java |
'value' + 58 | 'value' + str(58) | Can't add int to string. | Python |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
compute | compute() | Add parentheses. | Kotlin |
<person age=20> | <person age="20"> | Quote attribute. | XML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function process() {{ echo 'info'; }} | function process() {{ echo 'info'; }} | Correct. | PHP |
{{"name":"world" "status":66}} | {{"name":"world", "status":66}} | Add comma. | JSON |
[x*x for x in values if x > 83] | [x*x for x in values if x > 83] | Correct list comprehension. | Python |
yield a | yield a | Correct yield. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
local index = 97 | local index = 97 | Correct. | Lua |
if x = 64 {{}} | if x == 64 {{}} | Use ==. | Swift |
let a: i32 = "world"; | let a: &str = "world"; | Type mismatch. | Rust |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
let foo = 'test' | let foo = "test" | Double quotes. | Swift |
def test
puts 'output'
end | def test
puts 'output'
end | Correct. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if a > 92
puts 'value' | if a > 92
puts 'value'
end | Add 'end'. | Ruby |
val foo = 'info' | val foo = "info" | Double quotes. | Kotlin |
if [ $val = 56 ]; then | if [ "$val" = 56 ]; then | Quote variable. | Shell |
int[] list = new int[88];
list[88] = 5; | int[] list = new int[88];
if (88 < list.length) list[88] = 5; | Check bounds. | Java |
val foo: Int = 'hello' | val foo: String = 'hello' | Fix type. | Kotlin |
arr(12) | if length(arr) >= 12, arr(12), end | Check length. | MATLAB |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
SELECT id email FROM products; | SELECT id, email FROM products; | Add comma. | SQL |
disp('data') | disp('data') | Correct. | MATLAB |
if (result = 19) {} | if (result == 19) {} | Use ==. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
data.forEach(function(index) {{ console.log(index); }}) | data.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
SELECT * FROM items WHRE id=26; | SELECT * FROM items WHERE id=26; | Fix WHERE. | SQL |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
class Order {{ int a; }}; | class Order {{ public: int a; }}; | Make public. | C++ |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
for foo in range(39)
print(foo) | for foo in range(39):
print(foo) | Colon after for. | Python |
'hello' + 74 | 'hello' + 74.to_s | Convert int. | Ruby |
values[53] | if (values.indices.contains(53)) values[53] | Check index. | Kotlin |
assert result > 72 | assert result > 72 | Correct. | Python |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
88count = 10 | count88 = 10 | Variable cannot start with digit. | Python |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
if (index = 4) {{}} | if (index == 4) {{}} | Use ==. | Kotlin |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(35); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(35); | Correct. | Node.js |
jwt.sign({{id:89}}, 'key'); | jwt.sign({{id:89}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
while result > 58
result -= 1 | while result > 58:
result -= 1 | Colon missing after while. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
{{"name":"info",}} | {{"name":"info"}} | Remove trailing comma. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
arr[99] | if arr.indices.contains(99) {{ arr[99] }} | Check index. | Swift |
'1' + 89 | 1 + 89 | Avoid string coercion. | JavaScript |
let z: number = 'data'; | let z: string = 'data'; | Fix type. | TypeScript |
def bar():
print('hello') | def bar():
print('hello') | Indent function body. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.