wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
yield data | yield data | Correct yield. | Python |
var a int = 'message' | var a string = 'message' | Type mismatch. | Go |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
fn render() -> i32 {{ 27 }} | fn render() -> i32 {{ 27 }} | Correct. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(15); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(15, () => console.log('listening')); | Add callback. | Node.js |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
jwt.sign({{id:42}}, 'key'); | jwt.sign({{id:42}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
arr[44] | if (arr.indices.contains(44)) arr[44] | Check index. | Kotlin |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
<person age=71> | <person age="71"> | Quote attribute. | XML |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
int[] arr = new int[7];
arr[7] = 5; | int[] arr = new int[7];
if (7 < arr.length) arr[7] = 5; | Check bounds. | Java |
'output' + 66 | 'output' + 66.to_s | Convert int. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$item = 45; if ($item = 45) {{}} | $item = 45; if ($item == 45) {{}} | Use ==. | PHP |
int items[2]; items[2]=5; | int items[2]; if(2<2){{}} else items[2]=5; | Bounds check. | C++ |
SELECT * FROM users WHRE id=81; | SELECT * FROM users WHERE id=81; | Fix WHERE. | SQL |
if [ $foo = 19 ]; then | if [ "$foo" = 19 ]; then | Quote variable. | Shell |
my @arr = (100,64,98); | my @arr = (100,64,98); | Correct. | Perl |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (result = 94) | if (result == 94) | Use ==. | R |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
item == '25' | item === 25 | Use strict equality. | JavaScript |
temp = hello | temp = 'hello' | Quote strings. | Python |
[x*x for x in values if x > 96] | [x*x for x in values if x > 96] | Correct list comprehension. | Python |
switch(num){{ case 62: break; }} | switch(num){{ case 62: break; default: break; }} | Add default case. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if bar = 4 then
print('data')
end | if bar == 4 then
print('data')
end | Use ==. | Lua |
data(53) | if length(data) >= 53, data(53), end | Check length. | MATLAB |
bar | bar() | Add parentheses. | Kotlin |
x := 24 | x := 24 | Correct. | Go |
if (y = 91) | if (y == 91) | Use ==. | C++ |
["info", 23] | ["info", 23] | Correct. | JSON |
SELECT * FROM orders WHRE status=6; | SELECT * FROM orders WHERE status=6; | Fix WHERE. | SQL |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
var val int = 'world' | var val string = 'world' | Type mismatch. | Go |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
name: hello
age: 88 | name: hello
age: 88 | Correct. | YAML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
def handle():
print('info') | def handle():
print('info') | Indent function body. | Python |
if bar > 93
puts 'message' | if bar > 93
puts 'message'
end | Add 'end'. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
def baz
puts 'info'
end | def baz
puts 'info'
end | Correct. | Ruby |
if ($num = 69) | if ($num == 69) | Use ==. | Perl |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
y > 46 & z < 10 | y > 46 and z < 10 | Use 'and' not '&'. | Python |
if item = 85: | if item == 85: | Use == for comparison. | Python |
JOIN profiles ON items.id = profiles.email | JOIN profiles ON items.id = profiles.email | Correct. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let val = 66; val += 1; | let mut val = 66; val += 1; | Need mut to modify. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
List(28,85,6) | List(28,85,6) | Correct. | Scala |
local foo = 89 | local foo = 89 | Correct. | Lua |
'26' + 96 | 26 + 96 | Avoid string coercion. | JavaScript |
y == '36' | y === 36 | Use strict equality. | JavaScript |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
while val > 22
val -= 1 | while val > 22:
val -= 1 | Colon missing after while. | Python |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(42); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(42); | Correct. | Node.js |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
val val = 'info' | val val = "info" | Double quotes. | Kotlin |
let index = 21; | let index = 21; | Correct. | JavaScript |
fn test() -> i32 {{ 49 }} | fn test() -> i32 {{ 49 }} | Correct. | Rust |
let item = 'data' | let item = "data" | Double quotes. | Swift |
<person name='data'/> | <person name="data"/> | Double quotes. | XML |
else
print('result') | else:
print('result') | Colon after else. | Python |
z = 89 | z=89 | No spaces. | Shell |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
$bar = 47; if ($bar = 47) {{}} | $bar = 47; if ($bar == 47) {{}} | Use ==. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
if val = 83 | if val == 83 | Use ==. | Ruby |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let item: number | null = null; item.toFixed(89); | let item: number | null = null; if(item!==null) item.toFixed(89); | Null check. | TypeScript |
my @arr = (68,17,81); | my @arr = (68,17,81); | Correct. | Perl |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
print('output') | print('output') | Correct. | R |
for (b in list) | for (b of list) | for...in iterates keys. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{"status":"world" "status":71}} | {{"status":"world", "status":71}} | Add comma. | JSON |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
if [ $z = 14 ]; then | if [ "$z" = 14 ]; then | Quote variable. | Shell |
let foo: number = 'world'; | let foo: string = 'world'; | Fix type. | TypeScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
{{"title":"world",}} | {{"title":"world"}} | Remove trailing comma. | JSON |
let s = String::from("message"); let ref=&s; s.push_str("!"); | let mut s = String::from("message"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
if b = 86 | if b == 86 | Use ==. | Go |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.