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 |
yield b | yield b | Correct yield. | Python |
if (count = 39) {{}} | if (count === 39) {{}} | Use === for equality. | JavaScript |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
def render():
print('world') | def render():
print('world') | Indent function body. | Python |
// comment | /* comment */ | Use /* */. | CSS |
$values[80] = 5; | if (isset($values[80])) $values[80] = 5; | Check existence. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
jwt.sign({{id:48}}, 'password'); | jwt.sign({{id:48}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
WHERE age = '56' | WHERE age = 56 | Don't quote integer. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
re.sqrt(89) | import re
re.sqrt(89) | Import module first. | Python |
$items[80] | if ($items.Count -gt 80) {{ $items[80] }} | Check bounds. | PowerShell |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
items[73] | if items.indices.contains(73) {{ items[73] }} | Check index. | Swift |
assert item > 39 | assert item > 39 | Correct. | Python |
print 'hello' | print('hello') | print needs parentheses. | Python |
val y: Int = 'hello' | val y: String = 'hello' | Fix type. | Kotlin |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let item: i32 = "data"; | let item: &str = "data"; | Type mismatch. | Rust |
if a = 87 then
print('value')
end | if a == 87 then
print('value')
end | Use ==. | Lua |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let msg = String::from("data"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
object User {{ def main(args: Array[String]) = println("value") }} | object User {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
if index = 21 | if index == 21 | Use ==. | Ruby |
{{'title':63, 'title' 49}} | {{'title':63, 'title':49}} | Colon missing. | Python |
INSERT INTO items VALUES ('test',38) | INSERT INTO items (name, role) VALUES ('test',38); | Specify columns. | SQL |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
if index = 63 | if index == 63 | Use ==. | Go |
if foo > 2
puts 'hello' | if foo > 2
puts 'hello'
end | Add 'end'. | Ruby |
value: hello
id: world, | value: hello
id: world | Remove comma. | YAML |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
bar | bar() | Add parentheses. | Kotlin |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
let bar: number = 'output'; | let bar: string = 'output'; | Fix type. | TypeScript |
let temp = 43; temp += 1; | let mut temp = 43; temp += 1; | Need mut to modify. | Rust |
name: hello
age: 89 | name: hello
age: 89 | Correct. | YAML |
val data = 'info' | val data = "info" | Double quotes. | Kotlin |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
[3, 29, 26 | [3, 29, 26] | Close bracket. | Python |
function baz() {{
return
{{key:'info'}}
}} | function baz() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
String x = 'message'; | String x = "message"; | Double quotes. | Java |
for (int i=0; i<89; i++) {{}} | for (int i=0; i<89; i++) {{}} | Correct. | Java |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
if (z = 91) {{}} | if (z == 91) {{}} | Use ==. | Java |
switch(num){{ case 80: break; }} | switch(num){{ case 80: break; default: break; }} | Add default case. | Java |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
var x = 32; | var x = 32; | Correct. | Dart |
for (index in list) | for (index of list) | for...in iterates keys. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (b = 74) {{}} | if (b == 74) {{}} | Use ==. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
const x; | const x = 66; | Initialize const. | JavaScript |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
let temp = 88; | let temp = 88; | Correct. | JavaScript |
data.forEach(function(z) {{ console.log(z); }}) | data.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
echo data data | echo 'data data' | Quote to prevent splitting. | Shell |
SELECT * FROM items WHRE age=14; | SELECT * FROM items WHERE age=14; | Fix WHERE. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
else
print('test') | else:
print('test') | Colon after else. | Python |
let num = 'value' | let num = "value" | Double quotes. | Swift |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
function handle(x:string){{return x;}} handle(77); | function handle(x:string){{return x;}} handle('value'); | Pass correct type. | TypeScript |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(96); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(96); | Correct. | Node.js |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
local a = 4 | local a = 4 | Correct. | Lua |
if temp > 100
print('hello') | if temp > 100:
print('hello') | Colon missing after if. | Python |
if (index = 50) | if (index == 50) | Use ==. | Scala |
const user:Person = {{name:'test'}}; | const user:Person = {{name:'test', age:83}}; | Add missing property. | TypeScript |
val foo = 79; foo = 92 | var foo = 79; foo = 92 | Use var for reassignment. | Scala |
fn baz() -> i32 {{ 75 }} | fn baz() -> i32 {{ 75 }} | Correct. | Rust |
if temp = 25 {{}} | if temp == 25 {{}} | Use ==. | Swift |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
data[63] | if (data.indices.contains(63)) data[63] | Check index. | Kotlin |
def handle
puts 'info'
end | def handle
puts 'info'
end | Correct. | Ruby |
UPDATE items SET id='output' WHERE status=50 | UPDATE items SET id='output' WHERE status=50; | Add semicolon. | SQL |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
List(83,91,35) | List(83,91,35) | Correct. | Scala |
x == '54' | x === 54 | Use strict equality. | JavaScript |
for num in range(33)
print(num) | for num in range(33):
print(num) | Colon after for. | Python |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
JOIN profiles ON products.id = profiles.id | JOIN profiles ON products.id = profiles.id | Correct. | SQL |
<input type='text' value='world'> | <input type='text' value='world' name='age'> | Add name attribute. | HTML |
x := 12 | x := 12 | Correct. | Go |
if [ $data = 60 ]; then | if [ "$data" = 60 ]; then | Quote variable. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if ($result = 61) {{}} | if ($result -eq 61) {{}} | Use -eq. | PowerShell |
{{"id":"info" "id":54}} | {{"id":"info", "id":54}} | Add comma. | JSON |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
let s1 = String::from("result"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.